DeMar DeRozan scored 25 points — 22 in the second half — and the visiting San Antonio Spurs overcame an 18-point deficit to defeat the Toronto Raptors 105-104 on Sunday night.

DeRozan, who has scored 20 points in 11 straight games, sank two free throws with nine seconds remaining for what proved to be the game-winning points after Marco Belinelli’s 3-pointer had given the Spurs the lead.

Kyle Lowry sank a 3-pointer with five seconds left to pull Toronto within a point.

After San Antonio’s LaMarcus Aldridge missed two free throws with four seconds showing, Toronto’s Pascal Siakam missed a 3-point attempt at the buzzer.

Rudy Gay added 15 points, Derrick White had 13, Aldridge 11 and Dejounte Murray had 10 for the Spurs. Jakob Poeltl had four points and 10 rebounds.

Serge Ibaka had his eighth straight double-double with 21 points and 14 rebounds for Toronto. Norman Powell had 20 points, Lowry had 16 and Siakam 15.

Siakam (groin) and Powell (shoulder) returned to the Raptors lineup after each had missed 11 games. Toronto was 6-5 without them.

The Raptors led by as many as 18 points during the third quarter and took a 13-point lead into the fourth quarter.

The Spurs went on a 17-0 run to lead by three points with 5:31 to play. A layup by Patty Mills and White’s jumper increased the lead to nine points.

The Raptors responded with 10-0 run completed by Ibaka’s 3-pointer. Toronto took a one-point lead on Siakam’s free throw but Belinelli hit a 3-pointer with 28.8 seconds to play for the Spurs.

Siakam, showing no effects of the layoff, scored 12 points on 5-of-7 shooting in the first seven minutes and the Raptors led 28-21 after the first quarter.

The Raptors led 51-43 at halftime.

The lead reached 18 on a layup by Rondae Hollis-Jefferson with 4:16 left in the third quarter. DeRozan’s dunk brought the Spurs back to within 11 point in the final minute of the third.

Hollis-Jefferson’s tip shot with 1.7 seconds left in the third quarter gave Toronto an 82-69 lead.