Ray Allen scored 19 points and Kendrick Perkins hit a short fallaway with 2:11 left that wound up being the winner for Boston, which avenged a loss at home to San Antonio earlier this year.
Tony Parker led the Spurs with 25 points but missed four free throws in the final minute when San Antonio needed only two to tied the game.
Garnett scored 10 points and had four rebounds in just 15 minutes after coach Doc Rivers promised not to work his All-Star forward too hard in his return from a strained right knee.
Tim Duncan had 15 points for the Spurs who, like the Celtics, are fighting to hold onto their high playoff seeding. The loss cut San Antonio's lead over Houston to one game for the No. 2 seed with the Rockets coming to town Sunday.
The Spurs missed six consecutive free throws in the final 2:32, starting with two Michael Finley misses that would have given San Antonio the lead.
Paul Pierce had nine points and 12 rebounds for the Celtics.
Garnett missed 13 consecutive games for the Celtics and had not played since Feb. 19. He entered the game averaging 16.3 points and 8.8 rebounds this season.
Rivers said he wanted to gradually ease Garnett back into the lineup. He compared the game to training camp for Garnett while the rest of the Celtics fought to maintain playoff positioning in the East.
Boston went 7-6 over the past month without Garnett, a mediocre run that helped Cleveland build a 4 1/2-game lead for the best record in the East entering the game.
The Celtics have 12 games left before the playoffs, including final meetings at Cleveland and Orlando, which is just a game behind the Celtics for the No. 2 seed.
Rivers, coaching his first game since being fined $25,000 this week for criticizing a referee following a loss to Chicago, said the Celtics have precious time remaining to fully Garnett back into the rotation.
Putting Garnett back in now, essentially, was one of Boston's few options.
"We basically sat around and counted all the practice days before playoffs. It's not a lot of them," Rivers said. "And this is a solution."
The Celtics sure could have used Garnett down the stretch.