Updated

Matthew Stafford and the Los Angeles Rams are headed to the NFC title game.

Stafford, who was acquired in a trade with the Detroit Lions during the offseason, completed 28 of 38 passes for 366 yards with two touchdowns, and kicker Matt Gay booted a 30-yard field goal as time expired, to lead the Rams to a 30-27 win to hold off Tom Brady and the Tampa Bay Buccaneers on Sunday night.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

TAMPA, FLORIDA - JANUARY 23: Devin White #45 of the Tampa Bay Buccaneers defend as Odell Beckham Jr. #3 of the Los Angeles Rams runs with the ball in the first quarter of the game in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida.

TAMPA, FLORIDA - JANUARY 23: Devin White #45 of the Tampa Bay Buccaneers defend as Odell Beckham Jr. #3 of the Los Angeles Rams runs with the ball in the first quarter of the game in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida. (Kevin C. Cox/Getty Images)

The Rams will square off against the San Francisco 49ers for a third time this season, and the winner will advance to Super Bowl LVI.

Brady and the Bucs trailed 27-3 in the second half, but with the help of three Rams turnovers, Tampa Bay battled back and tied the game with 42 seconds left in the fourth when running back Leonard Fournette punched in a 9-yard TD run on fourth-and-inches. 

The Bucs, however, never got the ball back on offense.

TOM BRADY GETS INTO REF'S FACE AFTER HE TAKES SHOT TO LIP, BLEEDS

TAMPA, FLORIDA - JANUARY 23: Cooper Kupp #10 of the Los Angeles Rams runs with the ball in the third quarter of the game of the game against the Tampa Bay Buccaneers in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida.

TAMPA, FLORIDA - JANUARY 23: Cooper Kupp #10 of the Los Angeles Rams runs with the ball in the third quarter of the game of the game against the Tampa Bay Buccaneers in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida. (Mike Ehrmann/Getty Images)

On the Rams' ensuing drive, Stafford completed a 20-yard strike to wide receiver Cooper Kupp, which set up a 44-yard pass-and-catch to Kupp before Gay's game-winning field goal.

Stafford entered this postseason with an 0-3 career record, but he managed to lead the Rams to back-to-back victories to advance to the NFC Championship. Last week, he led Los Angeles to a wild-card round win over the Arizona Cardinals.

Brady, on the other hand, completed 30 of 54 passes for 329 yards with one touchdown and one interception. He was sacked three times and lost a fumble.

TAMPA, FLORIDA - JANUARY 23: Tom Brady #12 of the Tampa Bay Buccaneers is sacked by Aaron Donald #99 of the Los Angeles Rams in the second quarter in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida.

TAMPA, FLORIDA - JANUARY 23: Tom Brady #12 of the Tampa Bay Buccaneers is sacked by Aaron Donald #99 of the Los Angeles Rams in the second quarter in the NFC Divisional Playoff game at Raymond James Stadium on January 23, 2022 in Tampa, Florida. (Kevin C. Cox/Getty Images)

CLICK HERE TO GET THE FOX NEWS APP

The Bucs (14-5) season came to an end, and they will not have an opportunity to repeat as Super Bowl champions. 

As Tampa Bay enters the offseason, the question that looms is if Brady will return for a third year with the Bucs.

The Associated Press contributed to this report.