The USD men’s basketball team … up three at the Jenny Craig Pavilion with just seconds left … shooting free throws … missing … watching a West Coast Conference team that starts with P race down the floor and drain a three-pointer at the buzzer to force overtime.

It happened last year against Pepperdine, and the Toreros lost in OT.

It happened again Thursday night against Portland, and this time the Toreros reworked the script and gave it a new ending — a 78-75 overtime victory.

“The bottom line is, we won,” USD coach Bill Grier said. “Wasn’t a thing of beauty, we but won.”

And look at it this way: At least they learned something from last year’s fiasco.

“We just kind of talked about it, that we needed to come out (in the overtime) with high energy,” said sophomore forward Dennis Kramer, who had career highs in points (22) and rebounds (11), including a momentum-swinging three to open the extra period. “Last year against Pepperdine, we folded.”

That it even came to that tested the bounds of incredulity. USD (11-15, 6-8) led 60-43 with 8:22 left … and scored five points the rest of the way, and just two over the final 5½ minutes, and none over the final two minutes.

With 7.2 seconds left, the Toreros still led 65-62 and Chris Manresa was sent to the line for two free throws. Clank, clank.

Portland’s Kevin Bailey (18 points, all after halftime) dribbled across midcourt, cut right and fired up a three that went in as the buzzer sounded. A year ago against Pepperdine, the Toreros missed a free throw up three with four seconds left and Mychal Thompson made a 40-footer to force overtime.

Watching from the stands that night was high school recruit Chris Anderson, now USD’s starting point guard.

“That was in the back of my mind,” said Anderson, who finished with 10 points and 13 assists. “I told the guys in the huddle, ‘We are NOT losing this game.’ ”

And they didn’t after Kramer’s opening salvo from the top of the key, followed by a steal and layup by Darian Norris, followed by a Portland air ball. With 3.3 seconds left, Anderson was fouled and made the second of two free throws to make it 78-75 — only for Portland’s Tim Douglas to race across midcourt and launch a running three that hit the front rim.

Take away some lethargic moments early and careless moments late, along with a 12 of 21 night from the line, and the Toreros actually played well. They had 21 assists on 29 baskets and shot 8 of 15 on threes, which must have seen tepid to Portland after their 14 of 19 three-point shooting clinic in the first meeting last month.

These same teams likely will do it again March 1 in the WCC Tournament in Las Vegas. The Toreros seem entrenched in sixth place and Portland (6-20, 3-10) in seventh place, and six plays seven.

“Obviously we’re happy we won,” Anderson said. “But we can clean up some stuff.”