The Rockets led by two after a dunk by Montrezl Harrell before Ish Smith made a basket to tie it. James Harden missed a 3-pointer on the other end, and Johnson's 3-pointer made it 110-107.
Harden missed another 3-point attempt, and Johnson added the free throws to make it 112-107. Harrell added a layup after that but Tobias Harris tacked on two more free throws with eight seconds left.
Harden finished one rebound shy of a triple-double with 33 points, 12 assists and nine rebounds.
Boban Marjanovic, Detroit's 7-foot-3 backup center, led the Pistons with a career-high 27 points with 12 rebounds off the bench.
The Pistons used a 12-1 spurt, capped by four points from Marjanovic, to cut the lead to 94-93 midway through the fourth quarter. Houston missed seven straight shots in span before Eric Gordon ended the drought with a 3-pointer to make it 97-93.
A 3-pointer by Johnson tied it with about three minutes left before Harden made a pair of 3-pointers sandwiched around a layup by Henry Ellenson to give Houston a 105-101 lead.
Coach Mike D'Antoni rested starting center Clint Capela and said he'll rest other players in the last three regular-season games after Houston clinched the third spot in the Western Conference on Wednesday.
However, Harden and Patrick Beverley won't be among those who will sit out because they refused when he asked them.
Reggie Bullock made back to back 3-pointers early in the fourth quarter to get the Pistons within 6. But Houston made the next six points to extend its lead to 93-81.
Smith got the Pistons within 1 point with a jump shot with about nine minutes left in the third quarter before Houston used a 10-3 run, with two 3-pointers from Harden, to make it 69-61 midway through the period.
The Pistons scored seven straight points, with five from Harris, to cut the lead to 76-73 with about two minutes left in the quarter.
But Houston outscored the Pistons 9-2 the rest of the quarter to lead 87-75 entering the fourth. Lou Williams scored the seven points in that span and Harden capped the run with a reverse layup.
Houston led by as many as 11 in the first half and was up 54-52 at halftime.
Pistons: Michael Gbinije missed the game with a respiratory infection. ... Smith finished with 20 points. ... The Pistons had just six turnovers. ... Andre Drummond had 15 points and 11 rebounds.
Rockets: Anderson returned after missing the last six games with a sprained right ankle. ... Harden made seven 3-pointers for his 35th game this season with at least four 3-pointers. ... Beverley had six points and a career-high 13 rebounds.
Pistons: Visit Memphis on Sunday.
Rockets: Visit Sacramento on Sunday.