“We’re in the endgame now,” says Doctor Strange, mid-way through Avengers: Infinity War. He’s talking about the epic battle against the mega-villain Thanos, who is threatening to destroy half the universe. Stopping Thanos is going to require every Marvel superhero that Disney’s franchise rights can access. But Doctor Strange is also reminding us that Infinity War is the culmination of the most awesomely ambitious, successfully coordinated crossover project that cinema has ever seen, which has unfolded over a decade and nearly 20 movies.

But Infinity War could represent another kind of endgame. Superhero movies are undoubtedly the success story of modern Hollywood. They have been having their cake and eating it, combining lucrative spectacle with social and political relevance. And there’s no indication that their appeal is on the wane. But as time goes on, the superhero genre has been edging ever closer to its own contradictions, and something’s got to give.

In the predecessor to Infinity War, Captain America: Civil War, the US secretary of state visits the Avengers HQ and points out the elephant in the room. “What would you call a group of US-based, enhanced individuals who routinely ignore sovereign borders, who inflict their will wherever they choose, and who frankly seem unconcerned about what they leave behind?” he asks.

Like their audience, Iron Man, Captain America and co thought of themselves as flawed but noble superheroes uniting for a cause – until suddenly they were confronted with the possibility they might be dangerous, destructive, unregulated vigilantes. We’ve been seeing these awkward moments of self-awareness more and more in comic-book movies. Another one comes minutes later in the same movie. “In the eight years since Mr Stark identified himself as Iron Man, the number of enhanced persons has grown exponentially,” points out Vision, the Avengers’ cyborg super-being. “During the same period the number of potentially world-ending events has risen at a commensurate rate.” It’s a bit like the Mitchell and Webb sketch where a Nazi soldier wonders why they all have skulls on their cap badges and asks: “Are we the baddies?”

It’s a question worth asking: what makes superheroes the good guys? It’s taken as a given in these movies, but there’s a nagging sense that for all their tales of heroism and sacrifice and vanquishing alien threats to Earth, the superhero moral compass is no longer pointing in the right direction.

Traditionally, there was a very simple reason why superheroes were the good guys: they were on our side. “Us” being the US and its allies. DC Comics’ Superman pledged to “fight for the common man”. He took on the corruption and injustice that plagued his post-Depression society. Batman swore to avenge his parents’ death “by spending the rest of my life warring on all criminals”. Wonder Woman fought with truth and love. You could argue that Superman was more socialist-leaning, Batman more rightwing and Wonder Woman impossibly idealistic – but they were all on our side. Marvel’s 1960s stable complicated the issue a little. Titles such as X-Men and Black Panther broached civil rights issues and blurred moralities. But still, Captain America socked it to Hitler and Spider-Man knew that power comes with responsibility, and kept his crimefighting to neighbourhood scale. Good guys.

They were still the good guys when Sam Raimi’s 2002 Spider-Man kick-started the current comic-book movie era. The attacks of 9/11 were so fresh in the consciousness that the Twin Towers had to be airbrushed out of the movie’s posters, and its themes of inner courage and community spirit resonated. “You mess with one of us, you mess with all of us,” a random New Yorker yells at Spider-Man’s adversary. The first cycle of superhero movies followed a similar template, especially Iron Man, who took on Middle Eastern terrorists in his 2008 debut.

In previous eras, superheroes such as Michael Keaton’s Batman or Christopher Reeve’s Superman operated in more abstract fantasy worlds, but as superheroes began to interact with vaguely here-and-now political reality, their methods came under new scrutiny. Alan Moore’s seminal 1987 comic Watchmen was one of the first to suggest that people who enjoy dressing up in costumes and beating the crap out of people might be in need of psychological evaluation, or a war crimes tribunal. Vigilantism looks a lot like authoritarianism, which looks a lot like fascism.

Where does that leave a “good guy” such as Batman, who operates as both judge and jury, even applying the death penalty, with zero tolerance or oversight? Put him in the real world and you get someone like Vladimir Putin or Rodrigo Duterte.

As with the Avengers, Batman was called out on this in the recent Batman Vs Superman: Dawn of Justice. Bruce Wayne, AKA Batman, is told: “Civil liberties being trampled on in your city, good people living in fear ... he thinks he’s above the law”. The person probing him is the Daily Planet’s ace reporter Clark Kent, AKA Superman.

The other change was the direction of US and western politics. That post 9/11 moral certainty rapidly evaporated as the “War on Terror” and the invasion of Iraq and Afghanistan brought torture, extrajudicial killing, “collateral damage”, deception, mass surveillance and other abuses into the court of “the good guys”. Around the same time, superhero movies were entering their team-up phase, with the Avengers and Justice League. Questions of individual values became more complex questions of collective values – of power and its abuses, of loyalties personal, political, even planetary.

As the political soul of the Marvel cinematic universe, Captain America’s movies track the shift. In his 2011 debut The First Avenger, he’s a typical good guy: a Nazi-socking patriot with greatness thrust upon him. By the 2014 sequel, The Winter Soldier, his old-school moral certitude can’t get with the modern-day US government’s plans for universal surveillance and pre-emptive drone strikes. “This isn’t freedom; it’s fear,” he assesses, and turns his back on the government (rightly so: it turns out to have been infiltrated by the neo-Nazi organisation Hydra). In the era of Edward Snowden and contentious remote warfare, this was radical stuff for a superhero movie. By part three in 2016, Civil War, Captain America refuses the secretary of state’s demand that the Avengers agree to UN oversight and splinters off with a bunch of rebel superheroes. That sets the scene for a clash of opposing superhero teams.

A similar thing happens in Batman Vs Superman. And in both cases, the schism has been engineered by a hostile third party peddling false information and turning superheroes against each other. You could say these clashes reflect the polarised state of politics in the US, the UK and elsewhere, and foreign attempts to widen the divisions. Or they are just brazen attempts to sustain interest in the genre by orchestrating a bogus superhero face-off. Either way, the question again needs asking, who are the good guys here?

A useful way to examine the question is by turning it around and looking at some of the baddies. Let’s start with the most recent hit: Black Panther. Michael B Jordan’s antagonist Killmonger was widely regarded as one of the best things about the movie and with good reason: he’s not really bad at all. His grievances are actually perfectly valid: how could resource-rich Wakanda stand by and let all these atrocities – slavery, colonialism, world wars, racism – happen to their African brothers and sisters? Wakanda is like a Black Switzerland. It stands aloof and neutral (come to think of it, so does Wonder Woman’s home, Themiscyra). Killmonger is defeated, but he wins the argument: Black Panther realises he’s not the good guy! At the close of the movie, Wakanda begins to engage with the rest of the world, albeit on its own limited terms, which are a far cry from the armed uprising Killmonger had in mind.

This seems to be the pattern with a lot of superhero movies: the challenging political sentiments are not coming from the heroes; they’re coming from the villains. And the provocative ideas they raise are initially paid lip-service to, then conveniently forgotten in the heat of the third-act battle.

Avengers: Infinity War – the death, the destruction and Thanos – discuss with spoilers Read more

It happens again in Thor: Ragnarok. Yes, Cate Blanchett may be the goddess of death, Hela, but she reveals that Asgard’s wealth was built on colonial plunder. “Look at these lies,” she says, contemplating a medieval-looking ceiling fresco, “Goblets and garden parties, peace treaties. Odin, proud to have it, ashamed of how he got it.” She rips the fresco down to expose an older one underneath, showing scenes of violent conquest. “It seems our father’s solution to every problem was to cover it up,” she later says of Odin. Anyway, let’s have a big fight!

Take another example, Michael Keaton’s Vulture, villain of Spider-Man: Homecoming. His salvage firm is put out of business when the contract to clean up New York after the last Avengers battle is handed to a public-private partnership between the US government and Tony Stark, AKA Iron Man. That’s Stark, the billionaire weapons manufacturer and corporate predator who inherited his wealth. “A lot of the assholes who made this mess are being paid to clean it up,” one of Vulture’s colleagues observes. He seethes with understandable contempt for Stark, the Avengers and the one percent. “Those people up there, the rich and the powerful, they do whatever they want,” he says. “We build their roads and we fight all their wars and everything. They don’t care about us.” It’s a long way from, “You mess with one of us, you mess with all of us.”

Taking this idea of class war even further, before backing out of it, was The Dark Knight Rises, the third film of Christopher Nolan’s Batman trilogy. It was made at a time of the anti-globalisation Occupy Wall Street (OWS) movement, and class war was in the air. “When it hits, you’re all gonna wonder how you ever thought you could live so large and leave so little for the rest of us,” Anne Hathaway’s Catwoman tells Bruce Wayne (who, like Stark, is a hereditary billionaire arms-dealer).

Avengers: Infinity War review – colossal Marvel showdown revels in apocalyptic mayhem Read more

The villain, Tom Hardy’s Bane, bankrupts Wayne, exposes his political lies and provokes a popular uprising in Gotham City. At one point, he literally occupies Wall Street. “We take Gotham from the corrupt! The rich! The oppressors of generations who have kept you down with myths of opportunity, and we give it back to you … the people.” Again, you have to remind yourself that Bane is the bad guy. So does the movie: Bane’s rebellion devolves into show trials, executions and violence on the streets.

As usual, Batman gets to be the hero, restoring order and sacrificing himself for the sake of the Gothamites (or at least that’s what they think). The superhero movie’s flirtation with radical politics – also known as “socialism” – turns out to be another red herring. As the philosopher Slavoj Žižek noted at the time: “The actual OWS movement was not violent, its goal was definitely not a new reign of terror; insofar as Bane’s revolt is supposed to extrapolate the immanent tendency of the OWS movement, the film thus ridiculously misrepresents its aims and strategies.”

This brings us up to Infinity War’s villain, Thanos. With a name like that, you know he’s not a good guy. But nor is he textbook evil. He doesn’t want to build an empire or amass wealth or any of the usual despotic bad-guy things. He just wants to restore balance to the universe, indiscriminately. You could call him a Malthusian extremist. “The universe is finite, its resources are finite. If left unchecked it will cease to exist,” he explains. “So many mouths and not enough to go round.” You wouldn’t call that evil if David Attenborough had said it.

Thanos’s methods are hardly humane, but there is a logic to his argument: climate change and environmental destruction are inarguable threats. Human existence is unsustainable. But Avengers gotta avenge. Rather than debating the validity of Thanos’s arguments and acknowledging that something ought to change, the superheroes once again fight tooth and nail to preserve the status quo.

Avoiding spoilers, one thing Thanos’s rampage does achieve in Infinity War is to unite the divided factions of the Avengers. They’re all the good guys again. In the face of his existential threat, all other differences pale into insignificance. Here, at last, is a message that the outside world could really do with hearing.