TAMPA, Fla. >> Christian McCaffrey’s season debut was a mere afterthought once the 49ers finished up a 23-20 victory Sunday over the Tampa Bay Bucs.

Brock Purdy engineered a last-minute drive that left it up to Jake Moody, who made a 44-yard field goal as time expired to atone for three earlier misses.

Moody was mobbed by teammates as the 49ers improved to 5-4 on the season.

Walking by without immediately congratulating him, however, was Deebo Samuel. After Moody’s third missed field goal of the day, Samuel confronted him near the 49ers sideline, long snapper Taybor Pepper intervened, Samuel’s left hand took a swipe into Peppers’ throat, and coaching assistants intervened to separate them.

It didn’t have to be such a close game, only it was as the 49ers defense failed to hold a fourth-quarter lead and earlier special teams miscues opened the comeback door for Tampa Bay (5-5).

Purdy completed all four of his passes on the winning drive, with two targets apiece to Jauan Jennings and Ricky Pearsall.

Earlier in the fourth quarter, Purdy threw an 11-yard touchdown pass to George Kittle in the back left corner of the end zone to give the 49ers a 20-17 lead midway through the fourth quarter against the undermanned but gritty Bucs. Purdy scrambled around this Florida swampland before eventually throwing to a familiar spot, where Kittle also made a remarkable touchdown grab in the 49ers’ Sept. 29 win over New England.

The 49ers let another fourth-quarter lead slip away this season, however, as the Bucs pulled even at 20 on a last-minute, 26-yard field goal from Chase McLaughlin. Keying that drive were a dumbfounding barrage of defensive penalties, on Rock Ya-Sin (holding), Fred Warner (facemask), Maliek Collins (roughing the passer), and Evan Anderson (illegal hands to the face).

McCaffrey’s season debut undoubtedly enhanced the 49ers’ offense, as he totaled 68 receiving yards (six catches) and just 39 rushing yards (13 carries). Purdy passed for 353 yards and two touchdowns with no turnovers, while Baker Mayfield had just 116 yards for the Bucs.

The Bucs had their own say, primarily with their running backs leading their undermanned offense. Bucky Irving opened the fourth quarter with a 14-yard run on third-and-2, then followed that with a 12-yard touchdown dash past six defenders for the Bucs’ first lead of the game, 17-13.

The home crowd chanted “Buck-eee!” as the rookie rusher had 75 yards to that point. Fellow Bucs running back Raachad White scored Tampa’s first touchdown in the preceding quarter on a 9-yard catch-and run.

Pearsall’s first career touchdown put the 49ers ahead 7-0, once a replay confirmed Pearsall’s 56-yard catch-and-run. Pearsall caught Purdy’s pass in stride over the middle at the Bucs’ 30, then beat safety Antoine Winfield Jr. to the left pylon.

Pearsall celebrated with Jauan Jennings in a choreographed dance, then was handed back the souvenir football from fullback Kyle Juszczyk as more teammates happily mobbed him.

That initial scoring drive was kept alive by a third-down holding penalty on the Bucs. McCaffrey followed with a 5-yard run and 7-yard catch before taking himself out for a water break, where he watched the next two plays unfold with Jordan Mason in the backfield.

Pearsall, starting his second straight game and playing in his third overall since having his rookie season delayed by an Aug. 31 gunshot wound through his chest from an attempted robbery in San Francisco. On the 49ers’ first series Sunday, Purdy overthrew Pearsall on third down, after Pearsall wasn’s spotted breaking open the previous snap.

The 49ers’ first red zone opportunity with McCaffrey this season yielded only one touch for him (1-yard run). Purdy followed with consecutive incompletions (to Pearsall and George Kittle), setting up a Jake Moody field goal and a 10-0 lead 8:53 before halftime.

Tampa Bay responded with a field-goal drive just before halftime, and, in the process, they lost star left tackle Tristan Wirfs to a left-knee injury on a Cade Otton third-down conversion catch. DeVondre Campbell forced that 30-yard field goal with arguably his best play of the season, tackling Bucky Irving for a 3-yard loss on third down from the 49ers’ 9-yard line.

The 49ers’ next red zone series saw McCaffrey produce a 7-yard, third-down conversion catch to the Bucs’ 9-yard line, but then he came out for the next two plays. Running backs coach Bobby Turner appeared to hold him back from returning after a one-play break, and instead it was Isaac Guerendo failing to slow a Bucs’ pass rusher on a second-down sack.

The 49ers produced yet another special teams blunder in a season filled with them. Darrell Luter Jr., who had a punt ricochet off his foot in the Super Bowl, got pushed into Jacob Cowing by the Bucs’ Tavierre Thomas, resulting in a muffed punt and a turnover at the 49ers’ 21.

The Bucs converted that gaffe into a touchdown, with Baker Mayfield completing a 9-yard scoring toss to Rachaad White and tying the score at 10-10 only 3:02 after halftime.

Last season’s AP NFL Offensive Player of the Year, McCaffrey was a game-day scratch before the 49ers’ season-opening win over the New York Jets. He then went on injured reserve while recovering from Achilles tendinitis, a painful condition that led him to seek unspecified treatment or advice in Germany. He officially resumed practicing this past week, reported no setbacks, and came off IR on Saturday.

This being McCaffrey’s debut, it was his first full-speed, full-contact action since the Super Bowl, after which he scathed himself for a first-series fumble in the eventual overtime defeat to Kansas City.