A Super Bowl-record 108-yard kickoff return for a touchdown by Jacoby Jones to open the second half gave the Ravens a 28-6 lead but the 49ers scored 17 straight points after a 35-minute power outage and nearly pulled off a stunning comeback.

"Was just a great football game, the way that game played out when it was 28-6 and the lights went out, I just knew that with Jim Harbaugh being on that other sideline and those years that we've been together that that game was going to be a dogfight right to the end, that those guys were coming back," Ravens coach John Harbaugh said afterwards.

Trailing 34-29, the 49ers marched down to the Ravens' seven but failed to score on four tries, surrendering the ball on downs at the five with less than two minutes remaining.

Baltimore used up the clock and on fourth down, punter Sam Koch ran out of bounds in the end zone for a safety with four seconds left.

Joe Flacco, the game's Most Valuable Player, completed 22 of 33 passes for 287 yards, three touchdowns and no interceptions to lead the Ravens to their first title since the 2000 season.

"The next thing you know the Niners get right back into it and play great football and we just had to grind one out," said Flacco, who has guided the Ravens to the playoffs in each of his five NFL seasons.

Baltimore's lead evaporated because the 49ers' talented second-year quarterback, Colin Kaepernick, suddenly found the form that made him one of the league's most dangerous quarterbacks this season.

Despite a shaky first half, Kaepernick completed 16 of 28 passes for 302 yards and a touchdown. He also ran for 62 yards and a 15-yard touchdown on seven carries to finish behind Frank Gore (110 yards) as the 49ers' second-leading ground gainer.

Kaepernick's rushing score with 2:57 left cut the Baltimore lead to 31-29 but his pass attempt on the two-point conversion attempt was incomplete.

A 38-yard field goal by Justin Tucker with 4:19 left in the game hiked the Ravens' lead to 34-29, setting the stage for what could have been a Super Bowl-record comeback by the 49ers.

But the Ravens' defense, anchored by retiring linebacker Ray Lewis, came up big when it had to with a goal-line stand and handed the 49ers' franchise its first Super Bowl loss after five victories.