Stoudemire scored the Suns' final six points and blocked a John Salmons 3-point attempt with a second left, leading Phoenix to its sixth straight win. Seconds earlier, Ron Artest missed a shot for the Kings that would have tied it.
"Our defense definitely spurred us," Phoenix coach Mike D'Antoni said. "We got it going [offensively] then just got stagnant; we put it on cruise. We can't do that on the road."
Sacramento outscored Phoenix 24-14 in the fourth quarter but fell to 4-2 at home.
"One thing about the Suns is you are never out of the game," Sacramento coach Reggie Theus said. "They will allow you to get back in it."
Helping keep the Kings close was Artest, who had 13 of his season-high 33 points in the third quarter.
Artest made 12 of 23 shots and finished with 12 rebounds. But he also committed six turnovers and missed his final shot that would have tied it with 8.9 seconds left.
"I had to get it up and I thought it was going down," Artest said. "It felt like it was going right in but it didn't."
Stoudemire made two free throws with 2:49 remaining to give the Suns the lead for good at 96-94. He followed with a short jumper and two more free throws to put Phoenix ahead 100-94 with 1:35 left.
Sacramento pulled within two but couldn't complete the rally. The Suns got the rebound after Artest's miss, but Barbosa fumbled the ball out of bounds going for an uncontested layup with 3.1 seconds left. That led to Salmons' desperate attempt.
Kevin Martin missed five of his first six shots and finished with 15 points for Sacramento. Francisco Garcia had 14 points and Salmons added nine points and eight rebounds.
It was the second straight subpar game for Martin, the NBA's second-leading scorer. After opening the season with nine straight games of 20 or more points, including a career-high 43 last week against the Knicks, he was held to 19 in Sacramento's victory Sunday over Detroit.
"We tried to deny Martin the ball and make him take tough shots," Marion said. "He wasn't getting any fouls called like he usually does and he never got in a rhythm."
The Suns put together an 11-0 run in the third quarter to take a 72-55 lead. The surge started with a basket from Hill and ended with a Nash 3-pointer.
The Kings chipped away at the lead, with Artest banking in a shot from close range to tie it at 94 with 3:07 remaining.
Barbosa scored 15 points, Stoudemire had 14 and Hill added 13 to help the Suns take a 55-47 lead into halftime.
The two teams play again Wednesday night in Phoenix.
With a second left in the first half, Phoenix reserve Brian Skinner made the first 3-pointer of his career. A nine-year veteran, Skinner had only had one previous career attempt in the regular season. ... Chicago Cubs first baseman Derrek Lee watched the game from a courtside seat. ... Kings center Brad Miller fouled out early in the fourth quarter and finished with six points and four rebounds.