MINNEAPOLIS — There's little doubt it was a "trap game," and the Vikings fell right into it.

And then they dug themselves out.

Coming off an emotional prime time victory in Dallas, and heading into a bye week, the Vikings were a big favorite to dispatch the struggling Denver Broncos on Sunday before a record crowd of 66,883 at U.S. Bank Stadium.

Instead, they were shut out in the first half and fell behind by 20 points before Kirk Cousins threw three second half touchdowns passes to squeeze out a 27-23 victory.

Cousins' 32-yard scoring pass to Kyle Rudolph with six minutes remaining gave the Vikings (8-3) their first lead of the game.

Denver (3-7) drove to the Vikings' 4 with 10 seconds left, but Brandon Allen, in his second NFL start, threw three incompletions, and time ran out.

The Vikings became the first team in NFL history to score a touchdown on every possession of the second half and rally to win after trailing by 20 points at halftime.

NFL teams had been 0-99 over the past five seasons when trailing at least 20-0 at halftime. That's where the Vikings found themselves at the break, and it could have been worse. Andrew Sendejo's goal line interception late in the half prevented more Broncos points.

On Denver's opening drive, Allen hit rookie tight end Noah Fant with a 31-yard pass to set up Brandon McManus' 47-yard field goal for a 3-0 lead.

Then Allen found Courtland Sutton on a 48-yard completion over Vikings cornerback Xavier Rhodes the next time the Broncos had the ball. A 24-yard pass interference penalty on Rhodes later in the drive got Denver close enough for a 3-yard touchdown pass from Allen to Troy Fumagalli and a 10-0 edge.

As the Vikings stumbled offensively, Denver took a 17-0 lead on Andy Jovanovich's 1-yard run in the second quarter. A 38-yard pass to Tim Patrick was the key play in the drive, and the Broncos also converted a fourth-and-1 at the Vikings' seven on a 1-yard Sutton reverse.

The Vikings finally got a big play on Cousins' 34-yard pass to Stefon Diggs, but the gain was wiped out by a Riley Reiff holding penalty. To make matters worse, Reiff was beaten by Denver's Shelby Harris, who sacked Cousins and forced a fumble. Alexander Johnson recovered and the Broncos got a 29-yard field goal from McManus and a 20-0 lead.

Ameer Abdullah returned the ensuing kickoff for the Vikings but fumbled the ball away and Denver had another chance for points before the half ended when Josey Jewell recovered at the 18. But Allen was picked off by Sendejo.

The Broncos outgained the Vikings 217-51 in the half. Dalvin Cook, who had 183 yards from scrimmage in the victory over Dallas, touched the ball six times in the first half for eight yards.

The Vikings scored on their first possession of the second half. Cousins' 44-yard pass to Diggs set up a 10-yard scoring strike to rookie tight end Irv Smith Jr., and the Vikings were within 20-7.

But Vikings reserve Eric Wilson's offside penalty on a fourth down play kept Denver's next drive alive, and instead of punting they ate up time before McManus kicked a 41-yarder for a 23-7 lead.

Cook scored on a 3-yard run early in the fourth quarter, but the Vikings' attempt to cut the lead to eight failed when Cook was stopped on a shovel pass on the conversion run, and it was 23-13 with 13:25 remaining.

Wilson redeemed himself by recovering a punt-return fumble from teammate Mike Hughes on Denver's next possession, and the Vikings quickly got within 23-20 on a 54-yard bomb from Cousins to Diggs with 10:21 left.

Allen and Sutton combined on a 43-yard pass play to set up McManus for a 43-yard field goal attempt, but he missed it to the right with 8:15 remaining, and the Vikings took over at their own 33. Denver's defense was suddenly fragile and a five-play scoring drive was capped when Cousins rolled left and found a wide-open Rudolph for a 27-23 lead.

Cousins finished 29 for 35 for 319 yards.