SANTA CLARA, Calif. — Brock Purdy and the San Francisco offense did everything they could for the first 58 minutes in a nearly flawless performance. At the end, they were just spectators when the beleaguered defense finally came through with a stop.
Purdy threw a 38-yard touchdown pass to Jauan Jennings with 2:15 left, and the 49ers forced an incomplete pass on the final play from the 2 to beat the Chicago Bears 42-38 on Sunday night and set up a Week 18 showdown for the top seed in the NFC.
Caleb Williams drove the Bears (11-5) down the field in the closing seconds and had one last shot for the win. But Bryce Huff forced him out of the pocket and his throw short-hopped Jahdae Walker in the end zone to seal a sixth straight victory for the 49ers (12-4).
''For them to finish out the game like that, I was so happy for them. I was sitting there not being able to do anything but watch,'' Purdy said. ''To be able to celebrate was a cool team win. There's nothing like that. It was pretty special.''
That gave the 49ers a chance to win the NFC West and get a bye by beating Seattle (13-3) in the season finale on Saturday night. A win would give San Francisco home-field advantage and a chance to stay home all postseason, with the Super Bowl set to be played at Levi's Stadium on Feb. 8.
''We've earned this,'' coach Kyle Shanahan said. "This is the game we want. We love that it's here. We have an opportunity to never leave here again this year.''
The loss ends the Bears' hopes of earning the top seed. Chicago has already clinched the NFC North and can earn the No. 2 seed by beating Detroit next Sunday.
Purdy followed his career-high five TD-pass performance last week against Indianapolis by throwing for three scores and running for two to become the sixth player since the AFL-NFL merger with back-to-back games with at least five touchdowns.