BALTIMORE -- Before launching the biggest comeback victory in the history of the Baltimore Ravens, Joe Flacco first had to withstand the indignity of being booed by his usually supportive hometown fans.
Flacco didn't care for the treatment, although he could appreciate the sentiment. And it didn't prevent him from carrying the Ravens past the Arizona Cardinals 30-27 Sunday.
"You can take a few boos every now and then," Flacco said, "especially when you come back and win the game."
Using a fumble by Flacco and an 82-yard punt return by Patrick Peterson, Arizona scored three touchdowns during a five-minute span of the second quarter to take a 24-3 lead.
That's when many in the sellout crowd of 71,022 voiced their displeasure.
"I don't go to a lot of football games, but I probably would have wanted to boo if I was in the stands, too," Flacco said. "We weren't looking too good. We weren't playing too well."
Baltimore (5-2) answered with a 24-point run and moved in front 27-24 when Rice scored his third touchdown on the opening play of the fourth quarter.
Arizona (1-6) pulled even with a 45-yard field goal by Jay Feely with 8:55 left, but the Ravens won it with a 37-yard, beat-the-clock drive in the final minute.
After the Cardinals were forced to punt from deep in their own territory, Baltimore took over at the Arizona 44 with 52 seconds left. A 36-yard completion from Flacco to rookie Torrey Smith moved the ball to the 5, setting the stage for Cundiff's game-winner.
The Ravens' previous biggest comeback was from 19 points down against Tennessee in 2006.
"We woke up, plain and simple," said former Arizona star Anquan Boldin, who caught seven passes for 145 yards and was a key contributor in the rally.
Flacco went 31 for 51 for 336 yards, and Rice ran for 63 yards on 18 carries. In a 12-7 loss to Jacksonville on Monday night, the 5-foot-8 running back was limited to 28 yards on eight carries.
Arizona has lost six straight. Four of those defeats have been by four points or fewer.
"It's hard right now. Our guys are very disappointed after today's game because it was an opportunity to do something nobody thought we could do," coach Ken Whisenhunt said. "But our guys believe in what we're doing. If you look at what we did the first half, it shows that if we do it the right way, we can be a good football team."
Kevin Kolb threw for 153 yards and a touchdown, and Peterson became the eighth player in Cardinals history to have at least two punt returns for touchdowns in a single season. The last one to do it was Vai Sikahema in 1986.
The Ravens began the second half with an 80-yard drive in which Flacco went 5 for 5, including a 37-yarder to Boldin that set up a 1-yard touchdown run by Rice to make it 24-13.
"I felt like the way we came out at halftime is what turned it around," Baltimore linebacker Jameel McClain.
Late in the third quarter, Boldin caught passes of 21, 23, 27 and 9 yards during an 88-yard march that ended with another 1-yard TD run by Rice.
The momentum turned even further in Baltimore's direction immediately after the ensuing kickoff. On first down, Kolb was hit by Terrell Suggs while throwing a pass that was intercepted by McClain and taken 8 yards to the Arizona 22. Three plays later, Rice ran in from the 3.
Two holding penalties against the Ravens extended the Cardinals' bounce-back drive that ended with a field goal.
Mistakes by Baltimore also played a big part in Arizona's big second quarter.
With the game tied at 3, the Ravens' five-minute misadventure began when Flacco fumbled upon being sacked by O'Brien Schofield. Darnell Dockett recovered at the Baltimore 2, setting up a 1-yard scoring run by Beanie Wells.
The jeers increased when Peterson broke six tackles on his punt return. Thirteen seconds later, Richard Marshall picked off a pass that bounced off Smith's chest. That led to a 10-yard touchdown pass from Kolb to Early Doucet for a 24-3 lead with 3:46 remaining in the second quarter.
At that point, some fans were stunned into silence. Others felt compelled to voice their displeasure.
"When you hear the boos you know where it's coming from," Rice said. "It's not like they don't want us to do well. It was tough. At the same time, we held our head high and the boos turned into cheers in the second half."
A field goal by Cundiff cut the gap to 18 points at halftime.
The Cardinals placed TE Todd Heap (hamstring) on the inactive list. Heap played 10 seasons in Baltimore before signing with Arizona as a free agent this year. ... Ravens LB Ray Lewis missed a few plays in the first half with a right shoulder injury. ... Baltimore has won six straight at home. ... It was McClain's first career INT. ... The loss dropped Arizona into a last-place tie with St. Louis in the NFC West.