TAMPA, Fla. — A couple of weeks before the Saints visited the Tampa Bay Buccaneers at Raymond James Stadium on Sunday to close their season, New Orleans defensive coordinator Rob Ryan said at different times he had cursed at, yelled at and even cried in front of his players, who had allowed the second-most yards in the NFL.

During halftime of Sunday’s game, more screaming was in order.

The Saints had just surrendered touchdown drives of 80 and 74 yards to Tampa Bay, whose offense was ranked second-to-last in the NFL. They had permitted an offense that had a third-down success rate of 37.4 percent before Sunday to convert 8 of 11 third downs — 72.7 percent — giving the Bucs a 13-point lead at halftime.

When his players gathered in the locker room, he ripped his charges’ body language and apparent lack of desire to play in a game when nothing but pride was at stake.

“Have enthusiasm in what you’re doing,” Ryan said, according to Saints pass-rusher Junior Galette. “Act like you want to be here.”

It was uncertain Sunday whether Ryan would deliver another halftime speech as a Saints assistant. Though head coach Sean Payton gave Ryan an impassioned vote of confidence following the win at Pittsburgh on Nov. 30, calling his relationship with the coordinator “outstanding,” New Orleans’ defense subsequently was gashed for a staggering 900 yards in home losses of 31 and 16 points to divisional foes Carolina and Atlanta, which doomed its chances of qualifying for the postseason.

But the record should forever reflect that Ryan’s pep talk Sunday was a heck of a good one.

The Saints defense shut out Tampa Bay in the third and fourth quarters, and New Orleans beat the Buccaneers 23-20 to avoid its lowest season win total of the Payton era.

“Guys were like, ‘Hey, this guy really cares — we know he cares,’ ” said Galette, who gave the Saints their last two points on a sack in Tampa Bay’s end zone late in the fourth quarter. “We know how passionate he is. We started playing as a team ... and they couldn’t do anything.”

Galette wasn’t exaggerating. Tampa Bay — which intercepted Saints quarterback Drew Brees three times — was 1-of-6 (a dismal 16.7 percent) on third down in the second half. That translated into fewer offensive plays for Tampa Bay — and significantly less production.

The Bucs (2-14) rushed 24 times for a touchdown and 148 yards in the first half. In the second half, those figures plummeted to 15 carries for 35 yards.

Bucs quarterback Josh McCown was 12-of-20 for 106 yards and a touchdown during the first two quarters, but in the second half he only completed two passes for 9 yards. His third attempt bounced off receiver Tavarres King’s hands and into the grasp of Saints cornerback Keenan Lewis, setting up the Saints’ winning drive.

“I feel (that) I was beat on the (pass) route,” Lewis said of his second interception of the season and sixth since he joined the Saints in 2013. “But I pride myself on my ... ball skills. That’s something I cherish, but when I had seen it, I had to go get it.”

Lewis set the Saints (7-9) up at midfield late in the fourth quarter. Having already cut the deficit to 20-14 with a 1-yard touchdown run by Mark Ingram earlier in the quarter, New Orleans grabbed a one-point lead when Brees connected with receiver Marques Colston with 1:57 left.

Tampa Bay began its next drive at its 17, but a holding penalty and a 6-yard sack by defensive end Cameron Jordan had the Bucs looking at third-and-21 from their own 6. Galette then sacked McCown in the end zone for a safety that gave the Saints a three-point edge. The Saints then recovered an onside kick and killed the remaining clock.

It favored the Saints that McCown lost receiver Vincent Jackson to a groin injury early in the game. That facilitated New Orleans’ efforts to contain rookie wideout Mike Evans.

Evans set a Bucs franchise mark by catching his 12th touchdown this season, but he didn’t register a reception in the second half.

“Once we saw (Jackson was) out, we were able to put Keenan specifically on him,” Payton said. “It was ... a matter of cat-and-mouse.”

It didn’t take long before a smattering of skeptics in the corridors of Raymond James Stadium accused the Bucs of tanking in the second half because they knew a defeat would assure them the first pick of the 2015 draft.

Nonetheless, with a decision about whether to retain Ryan looming, the Saints’ defensive players were happy to leave the impression they did right as the offseason began Sunday.

“We definitely ended on a high note,” Jordan said. “We came into the second half and did what needed to do.”

Added Galette: “You’re told as a young kid to finish everything you do. Whether it’s breakfast or homework, finish whatever you’ve got to do. Unfortunately, we’re not in the playoffs but, hey, we finished strong, so we won’t (have) another bad taste in our mouth.”