Joe Flacco passed for 374 yards and led Cleveland to 13 points in the fourth quarter, including Dustin Hopkins‘ go-ahead 34-yard field goal with 32 seconds left, and the Browns withstood a Hail Mary on the final play to beat the Chicago Bears 20-17 on Sunday.

Flacco was intercepted three times but made some brilliant throws in the closing minutes to rally the Browns, including a 51-yard touchdown pass to Amari Cooper with 3:08 left that tied it at 17-all.

The Browns (9-5) got the ball back with 1:50 left and the 38-year-old Flacco, who was signed on Nov. 20 and made his third start for Cleveland, completed two passes to tight end David Njokufor 65 yards to set up Hopkins’ kick.

After blowing a 17-7, fourth-quarter lead, the Bears (5-9) nearly pulled off a stunning finish.

With no time left, Chicago quarterback Justin Fields lofted a pass from the 45-yard line to the end zone into a pack of players. Two Browns defenders batted it down, but it went directly to Bears wide receiver Darnell Mooney, who was lying on his back.

The ball bounced in and out of Mooney’s hands and he kicked it into the air, allowing Browns safety D’Anthony Bell to intercept it and avoid catastrophic ending for Cleveland.

The Browns, who have been battered by injuries all season, stayed in the No. 5 playoff spot in the AFC.

Tremaine Edmunds intercepted Flacco and returned it 45 yards for a touchdown right after halftime as the Bears built their 10-point lead.

Fields finished 19 of 40 for 166 yards, but couldn’t come with enough big plays in the fourth quarter.

Njoku had 10 catches for 104 yards, including a 2-yard touchdown in the second quarter. Cooper had four receptions for 109 yards.