NEW ORLEANS — From blowout to blackout to shootout, Joe Flacco and the Baltimore Ravens had just enough power to survive one of the most electric Super Bowls ever.

The outage flipped a switch for the San Francisco 49ers, but the Ravens used a last-gasp defensive stand to hold on Sunday night, 34-31.

America's biggest sporting event came to a half-hour standstill in the third quarter when most of the Superdome lights and the scoreboards went dark. By then, the Ravens had a 22-point lead.

Everything changed after that, though, and the 49ers staged a sensational rally before Ray Lewis and Co. shut it down. But there were plenty of white-knuckle moments and the Ravens (14-6) had to make four stops inside their 7 at the end.

For a Super Bowl with so many subplots, it almost had to end this way.

Flacco's arrival as a championship quarterback coincides with Lewis' retirement – with a second Super Bowl ring no less. The win capped a sensational month since the star linebacker announced he was leaving the game after 17 Hall of Fame-caliber years.

The sibling rivalry between the coaching Harbaughs went to John, older than Jim by 15 months.

"How could it be any other way? It's never pretty. It's never perfect. But it's us," John Harbaugh said. "It was us today."

At 4 hours, 14 minutes, it was the longest Super Bowl ever. Among the most thrilling, too.

The loss of power delayed the game 34 minutes and left players from both sides stretching and chatting with each other. It also cost Baltimore whatever momentum it built, and that was considerable after Jacoby Jones' 108-yard kickoff return and game MVP Flacco's three touchdown passes made it 28-6.

Back came San Francisco (13-5-1) in search of its sixth Lombardi Trophy in as many tries.

Michael Crabtree's 31-yard touchdown reception on which he broke two tackles made it 28-13. A couple minutes later, Frank Gore's 6-yard run followed a 32-yard punt return by Ted Ginn Jr., and the 49ers were within eight.

Ray Rice's fumble at his 24 led to David Akers' 34-yard field goal, but Baltimore woke up for a long drive leading to rookie Justin Tucker's 19-yard field goal.

San Francisco wasn't done challenging, though, and Colin Kaepernick's 15-yard TD run, the longest for a quarterback in a Super Bowl, made it 31-29. A 2-point conversion pass failed when the Ravens blitzed.

Tucker added a 38-yarder with 4:19 remaining, setting up the frantic finish.

Kaepernick couldn't get the Ravens into the end zone on the final three plays – there was contact on Crabtree on the final pass that appeared incidental, and Jim Harbaugh insisted it was pass interference.

Ravens punter Sam Koch took a safety for the final score with 4 seconds left. His free kick was returned by Ginn to midfield as time ran out.

In the first half, Flacco was as brilliant as Tom Brady, Joe Montana or Terry Bradshaw ever were in the NFL's biggest game. The only quarterback to win a playoff game in each of his first five seasons – his coach holds the same distinction – was nearly perfect.

It was typical of Flacco and Baltimore's postseason run. The Ravens stumbled into the playoffs with four defeats in its last five regular-season games as Lewis recovered from a torn right triceps and Flacco struggled. Harbaugh even fired his offensive coordinator in December, a stunning move with the postseason so close.

But that – and every other move Harbaugh, Flacco and the Ravens made since – were right on target. Just like Flacco's TD passes of 13 yards to Anquan Boldin, 1 to Dennis Pitta and 56 to Jones in the first half, tying a Super Bowl record.

New Orleans native Jones, one of the heroes in a double-overtime playoff win at Denver, seemed to put the game away with his record 108-yard sprint with the second-half kickoff.

Soon after, the lights went out – and when they came back on, the Ravens were almost powerless to slow the 49ers.

Until the final moments.

"The final series of Ray Lewis' career was a goal-line stand," Harbaugh said.

"It's no greater way, as a champ, to go out on your last ride with the men that I went out with, with my teammates," Lewis said. "And you looked around this stadium and Baltimore! Baltimore! We coming home, baby! We did it!"

It was a bitter loss for Jim Harbaugh, the coach who turned around the Niners in the last two years and brought them to their first Super Bowl in 18 years. His team made a similarly stunning comeback in the NFC championship at Atlanta, but couldn't finish it off against Baltimore.

Loading Slideshow...
  • Eye On The Prize

    The Vince Lombardi trophy is displayed before and San Francisco 49ers head coach Jim Harbaugh and Baltimore Ravens head coach John Harbaugh participate in a news conference for the NFL Super Bowl XLVII football game Friday, Feb. 1, 2013, in New Orleans. (AP Photo/Patrick Semansky)

  • Brotherly Love

    San Francisco 49ers head coach Jim Harbaugh, left, stands with his brother Baltimore Ravens head coach John Harbaugh before the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Gene Puskar)

  • Coin Toss

    NEW ORLEANS, LA - FEBRUARY 03: Players from the San Francisco 49ers and the Baltimore Ravens stand on the NFL logo for the opening coin toss during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Chris Graythen/Getty Images)

  • Baltimore 7, San Francisco 0

    Anquan Boldin #81 of the Baltimore Ravens catches a 13-yard touchdown pass in the first quarter over Donte Whitner #31 of the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Jamie Squire/Getty Images)

  • Baltimore 7, San Francisco 3

    David Akers #2 of the San Francisco 49ers kicks a successful 36-yard field goal attempt in the first quarter against the Baltimore Ravens during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Harry How/Getty Images)

  • Boldin's Bold Move

    Baltimore Ravens wide receiver Anquan Boldin (81) makes a 31-yard sideline catch against San Francisco 49ers defensive back Chris Culliver (29) during the first half of NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Elaine Thompson)

  • Defensive Intensity

    Baltimore Ravens defensive end Arthur Jones (97) celebrates after recovering a fumble by San Francisco 49ers running back LaMichael James during the first half of NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Elaine Thompson)

  • Baltimore 14, San Francisco 3

    Baltimore Ravens tight end Dennis Pitta (88) celebrates his 1-yard touchdown reception with center Matt Birk (77) against the San Francisco 49ers during the first half of the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Gerald Herbert)

  • Baltimore 21, San Francisco 3

    Baltimore Ravens wide receiver Jacoby Jones (12) catches a 56-yard touchdown pass during the first half of the NFL Super Bowl XLVII football game against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/David Goldman)

  • Reed-ing The Play

    Baltimore Ravens safety Ed Reed (20) returns an interception on a pass from San Francisco 49ers quarterback Colin Kaepernick in front of tight end Vernon Davis (85) during the first half of the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Elise Amendola)

  • Fake Field Goal Gone Wrong

    Baltimore Ravens kicker Justin Tucker (9) runs on a fake field goal during the first half of the NFL Super Bowl XLVII football game against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Tim Donnelly)

  • Baltimore 21, San Francisco 6

    San Francisco 49ers kicker David Akers (2) makes a 27-yard field goal during the first half of the NFL Super Bowl XLVII football game against the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Matt Slocum)

  • Baltimore 28, San Francisco 6

    NEW ORLEANS, LA - FEBRUARY 03: Jacoby Jones #12 of the Baltimore Ravens runs back a 108-yard kickoff return for a touchdown in the third quarter against the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Ezra Shaw/Getty Images)

  • Lights Out

    A power outage affects about half the lights in the Superdome during the second half of the NFL Super Bowl XLVII football game between the San Francisco 49ers and the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Dave Martin)

  • Waiting Game

    The San Francisco 49ers sit on the bench during a power outage in the second half of the NFL Super Bowl XLVII football game against the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Matt Slocum)

  • Concerned Faces

    Baltimore Ravens quarterback Joe Flacco (5), wide receiver Jacoby Jones (12) and linebacker Adrian Hamilton (54) watch the field during a power outage at the Superdome in the second half of the NFL Super Bowl XLVII football game against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Elaine Thompson)

  • Baltimore 28, San Francisco 13

    San Francisco 49ers wide receiver Michael Crabtree (15) reacts after scoring a 31-yard touchdown during the second half of the NFL Super Bowl XLVII football game against the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Matt Slocum)

  • Baltimore 28, San Francisco 20

    San Francisco 49ers running back Frank Gore, left, scores past Baltimore Ravens safety Ed Reed during the second half of the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Marcio Sanchez)

  • Defense Wins Championships

    San Francisco 49ers cornerback Tarell Brown (25) recovers a fumble by Baltimore Ravens running back Ray Rice (27) during the second half of the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Evan Vucci)

  • Baltimore 28, San Francisco 23

    NEW ORLEANS, LA - FEBRUARY 03: David Akers #2 of the San Francisco 49ers holds his left leg as he walks off of the field in the third quarter against the Baltimore Ravens during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. After missing a field goal but being bailed out by a running-into-the-kicker penality, Akers made a 34-yard field goal on the second try. (Photo by Ronald Martinez/Getty Images)

  • Baltimore 31, San Francisco 23

    Baltimore Ravens kicker Justin Tucker (9) makes a field goal against the San Francisco 49ers during the second half of the NFL Super Bowl XLVII football game, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/David J. Phillip)

  • Baltimore 31, San Francisco 29

    San Francisco 49ers quarterback Colin Kaepernick (7) scrambles during the second half of the NFL Super Bowl XLVII football game against the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. Kaepernick ran for a QB Super Bowl record 15-yard touchdown run, but the two-point conversion failed. (AP Photo/Evan Vucci)

  • Baltimore 34, San Francisco 29

    Baltimore Ravens kicker Justin Tucker, right, makes a 38-yard field goal during the second half of the NFL Super Bowl XLVII football game against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Matt Slocum)

  • No Flag

    San Francisco 49ers head coach Jim Harbaugh protests a non-call by the officials after a fourth down play during the second half of the NFL Super Bowl XLVII football game against the Baltimore Ravens, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Gene Puskar)

  • Baltimore 34, San Francisco 31

    NEW ORLEANS, LA - FEBRUARY 03: Punter Sam Koch #4 of the Baltimore Ravens holds the ball in the endzone as he takes a safety in the final minute of the fourth quarter against Chris Culliver #29 of the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Rob Carr/Getty Images)

  • On Pins And Needles

    Baltimore Ravens head coach John Harbaugh watches the final play of the NFL Super Bowl XLVII football game against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. The Ravens won 34-31. (AP Photo/Charlie Riedel)

  • A Super Celebration

    Streamers and confetti fall after the Baltimore Ravens won the NFL Super Bowl XLVII football game 34-31 against the San Francisco 49ers, Sunday, Feb. 3, 2013, in New Orleans. (AP Photo/Charlie Riedel)

  • Super Bowl MVP: Joe Flacco

    NEW ORLEANS, LA - FEBRUARY 03: Joe Flacco #5 of the Baltimore Ravens is lifted up by his teammates as they celebrate after they won 34-31 against the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Win McNamee/Getty Images)

  • Heart Of A Champion

    NEW ORLEANS, LA - FEBRUARY 03: Ray Lewis #52 of the Baltimore Ravens celebrates on the trophy podium after defeating the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. The Ravens defeated the 49ers 34-31. (Photo by Mike Ehrmann/Getty Images)

  • The Lombardi Trophy

    NEW ORLEANS, LA - FEBRUARY 03: Head coach John Harbaugh of the Baltimore Ravens holds the VInce Lombardi trophy as CBS announcer Jim Nantz looks on after the Ravens won 34-31 against the San Francisco 49ers during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. (Photo by Christian Petersen/Getty Images)

  • Celebration

    Ed Reed #20 and Ray Lewis #52 of the Baltimore Ravens celebrate after defeating the San Francisco 49ers as CBS Host Jim Nantz looks on during Super Bowl XLVII at the Mercedes-Benz Superdome on February 3, 2013 in New Orleans, Louisiana. The Ravens defeated the 49ers 34-31. (Photo by Jamie Squire/Getty Images)