It took a Nets substitute to beat a Spurs team full of them.Alan Anderson broke out of a recent scoring funk to score 22 points — including 17 of 21 Nets points during one stretch in the second half — to help the Nets pull away from the game but injury-riddled Spurs and claim a 103-89 victory in front of a sellout crowd of 17,732 inside Barclays Center Thursday night.

With the win, the Nets (22-25) improved to 12-4 since the start of 2014 — a run that came after a blowout loss in San Antonio on New Year’s Eve — heading into a game in Detroit Friday night.“I started attacking, and stopped settling for the 3 so much,” said Anderson, who shot 9-for-15 from the field but just 2-for-3 from 3-point range. “I just started attacking and once we started doing that, it started opening up the lane [for] kickouts, penetrating and dishing.

“Everything started opening up.”

After the Spurs (36-14), who were playing without Tim Duncan, Tony Parker, Manu Ginobili, Kawhi Leonard and Boris Diaw, cut the Nets’ lead to 68-66 late in the third quarter, the Nets looked as if they might risk being embarrassed on national television by losing to a severely depleted Spurs team on their home floor.

But that was before Anderson scored the final nine points of the quarter for the Nets, personally engineering a 9-2 run to send the Nets into the fourth with a 75-68 lead.

He then followed that up by scoring eight of the first 12 Nets points in the final quarter, as well as assisting on an Andrei Kirilenko for two of the other four points during that stretch, with his 3-pointer with 7:12 remaining giving the Nets an 87-77 lead they never would relinquish.

“Knowing that they didn’t have any shot-blockers [with Duncan out], our [goal] was to have Alan drive the ball and make something happen,” Nets coach Jason Kidd said. “Alan got to the basket, and he also made some big jumpers for us, too.”