Before 2008's Iron Man, audiences were used to seeing only two types of superheroes onscreen: a mild-mannered, incorruptible force for good, and a brooding genius with an unshakable moral compass, both equally determined to avenge and protect the innocent. Black and white. In that sense, Anthony Edward Stark was an aberration, thematically and heroically speaking.

Tony Stark was a complicated man. He might have seemed vaguely self-serving, but everything he did since 2008 was meant to serve the good of the people. His final act in the Marvel Cinematic Universe marks the death of a hero long portrayed as the bad guy, having proven over the course of nine movies that he just might be the best of the Avengers.

Here are Tony Stark’s greatest, and most heroic, MCU moments.

I AM IRON MAN

Tony Stark was Iron Man, with or without his armor. Unfortunately, in the beginning, this was hardly the case, and his fellow heroes often criticized him for his dependence on the suit, as well as on J.A.R.V.I.S. and F.R.I.D.A.Y. The general consensus seemed to be that Stark was only Iron Man when he was sufficiently suited.

Marvel sought to correct this in later movies. In fact, every MCU film Robert Downey Jr. has appeared in since Iron Man emphasized the character’s adaptability and growing independence from his armor, and how Tony Stark made Iron Man a superhero instead of the other way around.

RELATED: Endgame Fails to Give the Newest Avenger a Code Name

In Iron Man 3, Stark battled terrorism and infiltrated enemy bases with store-bought toys, bits and pieces of Mark 42 and nothing more than basic stealth skills. When the Mandarin bombed his Malibu home, Stark faced the intruders with prototype armor, relying purely on wit and sharp reflexes to survive the onslaught.

The film’s third act had the Armored Avenger engaging biologically enhanced villains with dysfunctional Iron Man suits, and ending the movie fully affirming his identity not as Tony Stark, but as Iron Man. Iron Man 3 also saw Tony finally parting with his miniature arc reactor, which had kept him alive since 2008. Fully content with who he was as a superhero, Stark then tossed the reactor off a cliff, allowing it to disappear into the sea.

RELATED: James Cameron Salutes Marvel After Endgame Topples Titanic's Record

Tony was thrust into a similar situation in Captain America: Civil War when Bucky Barnes rampaged through Vienna following his arrest. Stark had attended the signing of the Sokovia Accords as a civilian, and faced the Winter Soldier with nothing more than blind luck and an Iron Man glove.

In Spider-Man: Homecoming, Tony took his life’s creed to a whole new level when he mentored a misguided Peter Parker, reminding him of what truly defines a superhero -- not his suit or his gadgets, but his heart.

PROOF THAT TONY STARK HAS A HEART

When Captain America first met Tony Stark in 2012’s The Avengers, Rogers didn’t like what he saw in the younger hero. Cap is the all-American lionheart -- the perfect soldier -- and Stark was his polar opposite.

“I've seen the footage,” Cap said in the film. “The only thing that you really fight for is yourself. You're not the guy to make the sacrifice play. To lay down on the wire and let the other guy crawl over you. You may not be a threat, but you better stop pretending to be a hero.”

Steve Rogers couldn’t be more wrong.

RELATED: Avengers: Endgame Almost Featured Thor Trying to Kiss Valkyrie

Tony Stark grew up thoughtless and self-obsessed, but his time in a cave in Afghanistan back in 2008 changed him for good. The MCU is littered with Tony’s self-sacrifice, from The Avengers, when he guided a nuclear missile into a portal in space, to Iron Man 3, when he put Pepper Potts’ safety before his own and kept up the fight despite his worsening PTSD.

In last year’s Infinity War, Tony Stark willingly hitched a ride into space and, despite his initial protests, still put his life on the line to protect the Time Stone.

ALL FOR THE GREATER GOOD

Ever since Yinsen sacrificed his life in Afghanistan so that Tony Stark could finally start living for others, the young legionnaire never looked back. In Iron Man, he chose to honor Yinsen’s dying wish by closing down Stark Industries’ weapons division, waiving profits and foregoing prestige for the greater good. Later in the film, while fighting the Iron Monger, Stark ordered Pepper Potts to overload the building’s massive arc reactor in the hopes of killing Obadiah Stane, despite standing in the middle of the crossfire.

The Golden Avenger offered up the ultimate sacrifice in Endgame when he decided to prioritize other people’s happiness over his own, heeding the call of superheroing again for the sake of those who got dusted, and the loved ones they left behind. Tony could have lived a comfortable and relatively perfect life with his wife and daughter, the former of which was miraculously spared from the Decimation, but chose to save the world because it was the right thing to do.

RELATED: Avengers: Endgame's Time Travel Doesn't Need to Be So Confusing

He knew his chances for survival. He knew what Doctor Strange could have meant all along. He knew the consequences. He knew the risks. He knew exactly who he'd be leaving behind. He knew what he would be missing. He had always dreamed of ending the fight so "they could all go home," but this time he could tell he wouldn't be able to. And yet, he still dared to face his destiny.

When the time came to finally get rid of Thanos and his army, Tony wielded the Infinity Stones in one glove and snapped them all to dust, sacrificing his life in the process. A holographic message recorded before the time heist revealed that, although Tony would rather live peacefully with his family following the Decimation, he chose to leave that life behind so that other people could live in peace with their own families.

Directed by Joe and Anthony Russo, Avengers: Endgame stars Robert Downey Jr. as Iron Man, Chris Evans as Captain America, Mark Ruffalo as Bruce Banner, Chris Hemsworth as Thor, Scarlett Johansson as Black Widow, Jeremy Renner as Hawkeye, Brie Larson as Captain Marvel, Paul Rudd as Ant-Man, Don Cheadle as War Machine, Karen Gillan as Nebula, Danai Gurira as Okoye and Bradley Cooper as Rocket, with Gwyneth Paltrow Pepper Potts, Jon Favreau as Happy Hogan, Benedict Wong as Wong, Tessa Thompson as Valkyrie and Josh Brolin as Thanos.