The Cowboys could have lost Sunday’s game in the first quarter with four fumbles, three of them lost. Instead, they won it in the fourth quarter.

Dallas pulled out one of its most miraculous comeback victories in a team history full of them, scoring 16 points in the final 4:57 to win 40-39.

Greg Zuerlein made a 46-yard field goal on the final play after Zuerlein’s onside kick was recovered by the Cowboys with 1:48 left.

Atlanta had the game fully in control, up 39-24 late in the fourth quarter after leading 20-0 in the first quarter and 29-10 at halftime. But the Cowboys never said die.

Dak Prescott was 34-of-47 for 450 yards and a touchdown. He also ran for three scores on five carries for 18 yards. Rookie CeeDee Lamb caught six passes for 106 yards, and Amari Cooper had six receptions for 100 yards. Dalton Schultz caught nine passes for 88 yards and a touchdown.

It marked the first win for Mike McCarthy with the Cowboys, who welcomed 21,708 fans to AT&T Stadium. It saved McCarthy from second-guessing after two failed fake punts and a failed 2-point conversion with 4:57 remaining when a extra point would have drawn the Cowboys to within one score.

Matt Ryan threw four touchdown passes, with Calvin Ridley catching two of them, and Foyesade Oluokun forced three fumbles.

Prescott, Ezekiel Elliott and Schultz all lost fumbles. Elliott had another the Cowboys recovered.

The Falcons’ scoring drives covered 22, 52, 5, 31, 75, 56, 74 and 30 yards.