The Avengers

Given the complexity of what it set out to do, “The Avengers” is probably as good as anyone could have expected. I’m not referring to the logistics of working out the actors’ schedules or the cost of the special effects (which are not unprecedented), but to the narrative complications: “The Avengers” has to unite multiple characters who have wildly different pre-established personalities and backstories, come up with a plot line that gives each of them a reason to be involved, AND deliver a satisfying good-guys-vs-bad-guys superhero adventure.

Oh, and what else? Most of these superheroes are meeting each other for the first time? So we have to address their conflicting attitudes and motives, and can’t start with them already functioning smoothly as a team? On top of everything else this has to be an origin story, too?

That’s what I mean about “The Avengers” being about as good as an Avengers movie was ever going to be. Making something like this entertaining may sound like a no-brainer — you just gotta throw all those awesome heroes on the screen at the same time! — but doing it right is more complicated than that (as you know if you saw “The Expendables”). What they’ve come up with here has some clunky patches as things are being established, and the story is thin, standard fare. But when it works, it works exceptionally well. And it mostly works.

Things kick off at S.H.I.E.L.D. headquarters when an otherworldly power source called the Tesseract is activated, opening a space portal through which malevolent Norse demigod Loki (Tom Hiddleston) can travel to Earth. After using his magic space-scepter to brainwash a few S.H.I.E.L.D. team members into supporting him — including expert marksman Hawkeye (Jeremy Renner) — Loki makes off with the Tesseract. Whatever he wants with it, it can’t be good.

Nick Fury (Samuel L. Jackson), the one-eyed leader of the S.H.I.E.L.D. initiative, gets to work. Lethal spy and assassin Natasha Romanoff (Scarlett Johansson), aka Black Widow, is sent to recruit Bruce Banner (Mark Ruffalo), the brilliant scientist who turns into the Hulk when he’s angry. It seems that gamma radiation factors into Loki’s plans, and nobody knows more about the potential of gamma radiation than Bruce Banner. Billionaire playboy and smart guy Tony Stark (Robert Downey Jr.), also known as Iron Man, is recruited by Agent Coulson (Clark Gregg) to check out the research left by Dr. Erik Selvig (Stellan Skarsgard). Captain America Steve Rogers (Chris Evans), frozen during World War II but now thawed and a little upset at finding himself 70 years in the future, goes after Loki. Naturally, Thor (Chris Hemsworth) shows up too, since Loki is his brother and a known troublemaker.

The rest of the plot unfolds in the customary fashion, with the Avengers making progress in stopping Loki, suffering setbacks, learning more about what he’s after, and ultimately having a battle that wrecks several blocks of a major city (spoiler: it’s New York). The story, credited to genre veteran Zak Penn (“The Incredible Hulk,” “X-Men: The Last Stand”) and director Joss Whedon, doesn’t offer much originality; it replays the usual comic-book formula and just changes the names.

But the screenplay, which is attributed only to Whedon, more than compensates for the story’s averageness with consistently witty dialogue and a stream of terrific moments. Steve Rogers is an old-fashioned soldier, a loyal patriot and the epitome of a team player. He literally once jumped on a grenade to save his platoon — something the narcissistic and volatile Tony Stark would never do. Stark is also involved in the manufacture of weapons technology, which runs counter to Rogers’ mindset. “You may not be a threat,” he says to Stark in one heated moment, “but stop pretending you’re a hero.” Stark has plenty of sarcastic things to say to a Boy Scout like Rogers, as well as to Thor, whose courtly language and attire invite mockery. Bruce Banner, constantly struggling not to become “the other guy,” can bond with Stark over mathematical and scientific matters. I also love the detail of Agent Coulson being a gushing Captain America fanboy.

In short, while the characters themselves are flights of fancy, the way they interact with each other — and themselves, in battling their own weaknesses — makes sense. To me, that’s the movie’s greatest achievement. Putting Iron Man, Captain America, Thor, the Hulk, Black Widow, and Hawkeye in a room together is one thing. Portraying what happens next in a way that’s believable given what we already know about those characters is another. (Black Widow and Hawkeye don’t get as much focus as the others, but they have enough screen time and juicy character moments to register.) Loki is a typical rule-the-world villain, but Hiddleston plays him with sneering, dastardly charm. Mark Ruffalo might be the best of the modern Banners.

The action scenes are appropriately thrilling, shot and edited coherently and with gusto. Each Avenger’s individual strengths are used for the benefit of the team; it doesn’t feel like anyone has been wedged into the film merely out of obligation. I didn’t feel any emotional heft, but that’s been the pattern of these recent Marvel films, hasn’t it? Glossy, bang-pow comic-book fun, without much sentiment. I miss the affecting sensitivity of the first two “Spider-Man” films, but “The Avengers” doesn’t have room (or time) to explore anybody’s personal depths. If it has a flaw, that’s it, and I was mostly having too good a time to notice.

B+ (2 hrs., 22 min.; PG-13, a little profanity, a lot of action/sci-fi/superhero violence.)