As parts of the stadium went to black in the opening moments of the second half, the worst nightmare for the Baltimore contingent was that the Ravens could lose momentum at the exact point they were on the cusp of delivering a knockout blow in the Super Bowl, and taking away the ending this back-from-the-brink season deserved.

But Joe Flacco knew, even when a three-plus touchdown lead had evaporated and he was in agony on the sideline watching his defense be picked apart in the final minutes. “I think it’s fitting we won that way,” the MVP of Super Bowl XLVII said.

With these Ravens, it was the only way.

A rout wouldn’t have been right. It ended the only way it should have, with a rickety old linebacker in his last game, running on fumes, his stunned defense trying to stop a dreaming kid from playing Montana-to-Clark in the back of the Superdome end zone.

Fourth and the Lombardi trophy from the 5-yard line — all or nothing, just like this go-long-or-go-home ride the past six weeks.

“I was sitting there thinking there’s no way, there’s no way we stop them here,” Flacco said. “But we did. I don’t think there’s any better ending to a career than that — a goal-line stand by one of the greatest linebackers and one of the greatest players to ever play the game.”

Adversity’s Adults 34, the San Francisco 49ers 31.

This was how it needed to end: Chykie Brown making snow angels in the confetti, waving his arms as if he were flying through the roof of the Superdome, rejoining his teammates in the center of the field, the podium brought out and the hardware implausibly — no, impossibly — the property of the Baltimore Ravens.

No one who saw this team in December saw this night coming, this surreal victory over another favored team in the most bizarre Super Bowl anyone but the Ravens could imagine.

In hindsight, they needed the lights to go out, the momentum to shift, their mojo to disappear, their legs to tire, their middle linebacker to look as old as time. A blowout — it was 28-6 after Jacoby Jones’s 108-yard kickoff return to begin the second half — would not have been fitting.

Not for this team, this year. Not for linebacker Ray Lewis or safety Ed Reed. Not for Flacco or Jim Caldwell, who was installed as offensive coordinator in December. Not for wide receiver Torrey Smith or any of Coach John Harbaugh’s players.

“Baltimore, thanks for sticking with us,” an exasperated John Harbaugh said about 45 minutes after it ended. “Thanks for believing in us. We did this together. The final series of Ray Lewis’s career was a goal-line stand for the Lombardi Trophy. It wasn’t perfect. It wasn’t pretty. But it was us.”

The drama at the end gave them everything they wanted: the trophy; Flacco as cool as could be, headed for Disney World; Lewis, going out a victor on the last night of his incomparable career; Smith, who lost his brother in a motorcycle accident earlier this season, bear-hugging his offensive coordinator, the only African American calling plays in a 67-percent black NFL at the time he was elevated to that position, plays that shredded one of the best defenses in football. The man who didn’t get so much as an interview for a head-coaching job was living proof of the sham Rooney Rule.

And Harbaugh talking about the resolve that characterized the past year.

They needed to be counted out. That’s been their mantra. The team that lost four of its last five regular season games and eked into the playoffs with an underwhelming quarterback directing a vanilla offense was supposed to be too old on defense and too predictable on offense to do much after their heartbreaking loss to New England in last year’s AFC championship game.

They entered the postseason a longer shot than the Washington Redskins to win the grail, and after disposing of Indianapolis in the first round it was pretty much decided that Lewis’s last game would be in Denver.

Then Flacco threw a bomb at the end of regulation, behind the defense, and the Ravens had new life. They beat Peyton Manning in overtime. Then they thrashed Tom Brady in Foxborough, Flacco outplaying the two premier quarterbacks of his era in back-to-back weeks.

The impossible was within reach, but ahead were these hard-hitting 49ers and their read-option quarterback, playing a shell game in the backfield, trying to ruin this whole magical night.

The smoke had not yet cleared from Beyonce’s halftime show when Jones scored. But moments later, the lights went out, a delay of more than 34 minutes that ended with Ravens and 49ers players stretching, as if a local municipality had forgotten to pay the utility bill on its Little League field.

And when the lights came back on, the Ravens were in a haze. They gave up huge yardage and scores to Colin Kaepernick. Ray Rice fumbled inside his own 30. They looked awful, as the 49ers did in the first half. The Ravens looked like the team that nobody could see here as they floundered at the end of the season.

Now, they are the great hope. They showed anybody has a shot if they can find themselves in January. The idea that you can get healthy and hot at the same time and knock the paper champions off the mountain in the postseason has been perfected by a 10-6 wild-card Green Bay team and twice by Eli Manning and the resilient Giants, including last year’s Super Bowl victory over the Patriots.

But none of those teams looked worse or more unfit to be champion than the Ravens did in December, after they were blown off their own field by the Broncos and looked so pedestrian that John Harbaugh decided to fire Cam Cameron and give Caldwell the play-calling duties.

This is the most impressive test of resilience ever in the Super Bowl, given where Baltimore was less than six weeks ago.

Between their defense growing old at key positions, in-season personal tragedy with Smith losing his brother, controversy over Lewis’s reported use of performance-enhancers during Super Bowl week and, oh yeah, two of the best teams in the AFC and these 49ers, no team has overcome more to raise that trophy and feel what the Ravens are feeling right now.

Fourth-and-5 for the Lombardi Trophy — and they stopped the kid and a team about to ruin their dream. They cleared the final hurdle in the most impressive journey a champion has ever had to take.

The rout, a win by blowout, would not have felt as right. They needed the theater, someone to tell them they couldn’t right before they did. Said Reed, smiling big, “After everything we’ve been through, it was the only way it could end.”

For previous columns by Mike Wise, visit washingtonpost.com/wise