So it says a lot about Mr. Gunn, 46, who came to Hollywood by way of small-town Manchester, Mo., and a career in B-movies, that he believes he can resist the worst impulses of the studio system even while he works within it.
To his mind, the “Guardians of the Galaxy” movies are still fulfilling his urge to tell stories about characters with complex, interconnected needs — even if one of those characters happens to be a talking raccoon — and to maintain the innovative traditions of his moviemaking forebears, at price tags upward of $170 million.
Thinking back to the moment when he was offered the first “Guardians,” Mr. Gunn said recently in a phone interview from his home in Malibu, “I saw it as an opportunity. I could truly fill a hole of what was missing.”
Mr. Pratt, who was elevated from a TV sitcom star to an A-list film actor with help from the first “Guardians,” said that project allowed “James to earn Marvel’s trust, so that he could really make the movie that he’s always wanted to make.
“They provide the capital for this kind of a movie, and he does everything else.”
Mr. Gunn, a former disciple of Lloyd Kaufman, the schlock-movie impresario and Troma Entertainment co-founder, wrote that company’s outrageous Shakespeare sendup “Tromeo and Juliet” with Mr. Kaufman, then graduated to studio projects like “Dawn of the Dead” and the live-action “Scooby-Doo” movies.
After writing and directing the sci-fi horror pastiche “Slither” in 2006 and the violent superhero comedy “Super” in 2010, Mr. Gunn said he knew he was on Marvel’s list of directors for “Guardians,” though not high on it.
Kevin Feige, the president of Marvel Studios, said that Mr. Gunn “was a name amongst many,” but added that “the secret of our list is, they’re not listed in order of preference.”
“It really is based on the vibe of the meetings and discussions we have,” Mr. Feige said, “that we come to our decision of who we want to collaborate and live with for many years to come.”
Given that “Guardians of the Galaxy” was based on a Marvel comic that was not especially popular at the time, filled with low-level characters who you wouldn’t even ask to cater an Avengers staff party, perhaps Mr. Gunn was ideally suited for the material.
After one preliminary meeting with Marvel producers, Mr. Gunn could not quite get over the character of Rocket Raccoon, a bad-tempered, gun-toting anthropomorphic animal with the voice of Bradley Cooper.
“I was like, ‘O.K., a talking raccoon – that’s a stupid idea,’” Mr. Gunn recalled. “But let’s say there was a talking raccoon. How would he exist?”
Once he connected to the “extraordinary sadness” of the character’s Frankenstein-like origins, Mr. Gunn said, “it drove the whole thing for me, and I found it tonally interesting because of that.”
To him, the first “Guardians” presented a chance to reinvigorate the drab, dreary space-opera genre with the buoyancy of favorite films like “Raiders of the Lost Ark” and the gaudy colors of “Flash Gordon.”
The assignment came with many conditions, including a cast of characters who had to be established within the first 20 minutes, like Peter Quill (Mr. Pratt), a would-be outlaw who calls himself Star-Lord; and Gamora (Ms. Saldana), a green-skinned alien assassin. There was an existing script by Nicole Perlman and a preset release date, leaving Mr. Gunn little time to make changes. (He and Ms. Perlman shared screenplay credit on the film.)
Mr. Feige said he knew he’d made the right choice when he saw what was on the cover of Mr. Gunn’s revised script treatment: A color photo of a vintage Walkman, a personal artifact treasured by Peter Quill, who uses it to play his favorite classic-rock songs.
“Before I even turned the page,” Mr. Feige said, “I thought, ‘This is perfect.’”
Ms. Saldana describes herself as “a sucker for sci-fi” (she also plays Uhura in the current “Star Trek” franchise), but said she often finds such screenplays challenging to read. “First of all, I think in Spanish,” she explained, “and I’m dyslexic.”
But in early conversations with Mr. Gunn, she said, “I felt in his tone, his confidence, that he knew exactly what he was going to do.”
Mr. Gunn, she said, represented “what is great about being a geek,” adding, “It just means that you’re curious, you’re confident, and once you make a discovery, you show it off with pride.”
Mr. Gunn found making movies on a megabudget Marvel scale invigorating — “On my last movie, I did 54 setups a day with one camera, so this is easy,” he said — but also intimidating.
“I would wake up in a cold sweat at 3 a.m. thinking I might be making ‘Pluto Nash 2,’” he said, referring to Eddie Murphy’s costly outer-space flop from 2002. “There were moments where I was consoling myself with the thought that I could go teach.”
That said, the success of the movie — which was a hit not only with audiences but with critics, and enjoys a 91 percent positive rating on Rotten Tomatoes — bought a lot of leeway for Mr. Gunn, who started writing a second “Guardians” film as soon as the first one was released.
“I got to start from scratch with the story,” he said. “The emotional and action plots were completely intertwined, and all organic and one thing.”
Asked if Marvel dictated any plot elements this time, Mr. Gunn said: “None. Zero.” (Mr. Feige said, “The notion that we require things or crowbar things into one movie so it serves another” was “overblown.”)
“The only restrictions this time are things that we set up in the last movie,” he added. “Other than that, it can go anywhere we want it to.”
Mr. Pratt said that when they met to talk about “Vol. 2,” soon after the first “Guardians” opened, Mr. Gunn was deeply concerned about repeating himself.
On the original film, Mr. Pratt said, “we benefited from people’s lowered expectations. We could sneak in and be this movie that they didn’t see coming. Now they’re waiting in line for this.
“So how do you surprise somebody who’s lying in wait? He did that by just throwing away the formula of the first movie.”
For “Vol. 2,” Mr. Gunn immersed himself in sources as disparate as the artwork of Jim Steranko, a comic-book illustrator known for his surrealism, psychedelia and sensuality; and the visually sumptuous movies of Wong Kar-wai.
He came away inspired to add characters like Ego, a living planet who is revealed to be Quill’s father and who, in his humanoid form, is played by Kurt Russell.
What connects Ego to the established “Guardians” ensemble, Mr. Gunn said, are themes of isolation and yearning to belong. “At the center of this was a lonely being who had been floating out there for eons,” he said, “dreaming if other life exists out there somewhere.”
Mr. Gunn’s name also appeared earlier this year on “The Belko Experiment,” a gruesome thriller about an office complex in Colombia whose employees are forced to murder each other.
Mr. Gunn wrote the screenplay and had been preparing to direct it many years ago, but withdrew when he and the actress Jenna Fischer were divorcing in 2008.
“Suddenly, I was like, ‘You know what? I don’t want to make a movie about people who are killing each other,’” Mr. Gunn recalled.
When MGM and Orion Pictures revived “The Belko Experiment,” Mr. Gunn stayed on as a producer. “For me it was mostly an excuse to take time off and hang with all my actor friends who I put in the movie,” he said.
He explained, “There’s a bit of an edgy, violence thing in me, that maybe I need to scratch, whether that’s healthy or not.”
But since he started working on the “Guardians” movies, Mr. Gunn said, “I feel like I’ve changed a lot in what stories I want to tell, through this process.
“It’s very easy for me to go to the cheap shock. In some ways, it’s an emotional cover-up, as opposed to feeling sadness or dealing with the more vulnerable side of my nature.”
Mr. Gunn has already announced he plans to write and direct a third “Guardians of the Galaxy” film, and said that working on any other established franchise would probably feel too constrictive.
When Marvel first sought him out, he said, “I kind of did want to make a ‘Hulk’ movie, but at this point, that isn’t what I would want to do. Working in that ‘Avengers’ thing, you have to work within a pre-existing system. It’s more exciting to me to create something new.”
He added: “I have a story of a raccoon I need to tell right now. Nothing else really appeals to me. I love the raccoon as much as I love my family members.”