Coach Gregg Popovich's strategy worked. The Spurs held Harden to 16 points and got their 10th straight victory, 104-103, and a leg up in the playoff standings.
Tim Duncan had 29 points and blocked Harden's layup with 2.9 seconds left to secure the victory.
San Antonio jumped into the third spot in the Western Conference and Houston dropped from third to sixth.
Popovich was pleased with the way his Hack-A-Smith routine changed the game.
"Absolutely, I'd trade it any day rather than have James Harden with the basketball," Popovich said. "That's kind of scary."
The Spurs had a four-point lead when Harden made a layup for his first points of the half with less than 90 seconds remaining.
Duncan missed a layup before Harden made a 3-pointer with 28.9 seconds left to get Houston to 104-103. Tony Parker turned it over to give Houston one last shot.
But Duncan blocked Harden's shot and grabbed the rebound to secure the victory.
"It was a good opportunity for me to get redemption at the end," Duncan said, noting his missed layup that would have put it away earlier.
Harden summed up the play simply.
"Got to finish," he said. "I've just got to finish."
The close game ended a streak of nine straight wins by at least 12 points, which had tied an NBA record.
Harden, who entered the game leading the NBA in scoring, was kept well below his 27.6 average, with San Antonio intentionally fouling Smith 12 times in the second half. Smith went 12 of 26 from the line and led the Rockets with 20 points.
"It was a good strategy," Smith said. "I stepped to the line confident, but I wasn't able to make the majority of my free throws."
The Spurs won the season series 3-1.
Dwight Howard added 12 points with 14 rebounds for the Rockets.
The Spurs continued to intentionally foul Smith in the fourth after he went 3 of 10 from the line on five intentional fouls in the third quarter. But Smith, who entered the game shooting 52 percent from the foul line, got better when they started it again in the fourth, making five of his first six. A turnover by the Spurs gave Houston a fast break after that and Smith finished it with an emphatic one-handed dunk to tie it at 92.
That didn't deter San Antonio from fouling Smith more, doing it on Houston's next four possessions. Smith made just two of his next eight free throws while the Spurs added six points to give them a 98-94 lead.
Boris Diaw accidentally fouled Smith after that and he made both free throws to start at 4-0 run for the Rockets that tied it again.
Houston was up by 3 when the Spurs scored eight straight points to end the third and give them a 80-75 lead. Patty Mills made two 3-pointers to cap that run, with the first one giving San Antonio its first lead of the game.
The Spurs tied it at 64-all with about four minutes left in the third, but Manu Ginobili turned it over the next time down the court and Ariza hit a 3 on the other end to put Houston on top 67-64.
The Spurs fouled Smith on Houston's next two possessions and he made just one of four free throws. Mills made a 3-pointer after that, but another 3 by Ariza gave Houston a 71-68 lead.
A dunk by Duncan cut it to 1 and Smith missed three of four free throws again as they intentionally fouled him two more times.
Duncan made another basket and San Antonio fouled Smith on purpose once again and he made one of two to leave the Rockets up 73-72.
Smith went to the bench after that and a basket by Corey Brewer made it 75-72 before San Antonio's run to end the third.
The Rockets had a 48-46 lead at halftime.
The Rockets jumped out to a 12-0 behind eight points from Ariza. The Spurs used a 9-3 run at the end of the first quarter to cut the lead to 30-23 entering the second.
Spurs: F Tiago Splitter missed his fourth straight game with tightness in his right calf. ... Leonard finished with 18 points.
Rockets: F Donatas Motiejunas is out of the season after back surgery. The 7-foot Motiejunas last played on March 25 and had minimally invasive spine surgery called a lumbar microdiscectomy. ... Houston made 32 of a season-high 53 free throws. ... Ariza had 19 points.
Duncan on how much attention he pays to the ever-changing playoff standings: "I try to figure out where we are, where we could be and it gives me a headache, so I just stop looking."
Spurs: Host Phoenix on Sunday.
Rockets: Host New Orleans on Sunday.
Minnesota Timberwolves point guard Ricky Rubio's mother has died after a long battle with lung cancer.
Would David Fizdale be a good hire for the Grizzlies? Will the team keep free agent Mike Conley? Our crew forecasts the future for Memphis.
David Fizdale, an assistant with the Heat, has been offered the head-coaching job with the Grizzlies and the sides are working on a contract, according to ESPN and a report from The Vertical.