McGrady also had 12 assists to help offset Artest, who matched a career high with 39 points.
"When you're struggling for three quarters, your best player has to take over in the fourth quarter, I don't care what he has to do," said McGrady, who missed nine of his first 14 shots before his big finish. "I knew I was struggling. That's why I wanted to attack in the fourth quarter."
Artest hit 12 of 23 shots, went 10-for-11 from the free-throw line and grabbed eight rebounds. He had the ball in his hands in the final seconds of regulation, but slipped on the floor and lost it.
Artest knew he was approaching his career high, set in January against New York, but he was more concerned with getting the win.
"Any time you reach that point, you know where you are," Artest said, "but I wanted to come away with a victory. We didn't get it."
Artest's free throws with 1:47 left in overtime put the Kings up 104-103, but McGrady hit a turning fadeaway over Artest with 1:29 left to put Houston up for good.
McGrady admitted the Rockets were outplayed for three quarters, but fortunately stayed close enough to pull it out.
"When we started to realize it was a winnable game, we started playing with great energy, getting out in transition, getting some stops, steals and knocking down shots," he said. "I felt like if we could keep it close in the fourth quarter, it was going to be our game."
Shane Battier added 25 points, including a 3-pointer in overtime, and grabbed eight rebounds for the Rockets, who won for the first time in 14 games when they trail after three quarters.
Battier remembers facing Artest in AAU games when the two were teenagers. And he was just as difficult to guard then.
"He's been tough for a long time," Battier said. "He's so tough going to the basket and he's a competitor."
Kevin Martin added 21 for the Kings, who've lost two in a row after having a five-game winning streak snapped.
Artest and McGrady put on a show in the final minutes of the fourth quarter.
Artest converted a three-point play with 5:15 left, then added a pull-up jumper with 4:36 to go to put the Kings up 92-83.
McGrady suddenly started hitting, sinking a 3 and a pull-up jumper to draw the Rockets to within four.
After two free throws by Bonzi Wells, McGrady banked in a 3 to put Houston ahead 93-92. McGrady put his arms out to his sides in mock disbelief as he trotted down the court.
The Kings missed five straight shots and McGrady stretched the lead to three when he faked out Salmons and swished a jumper from the top of the key, letting out a scream after the shot fell.
McGrady thought that basket might turn out to be the game clincher.
"That was a really big shot for my team," he said.
But after a Kings time out, Artest drove for a layup. McGrady answered with a drive, but Artest made a 3 from the corner with 40.8 seconds left to tie the score at 97.
"When he's making his outside shots, he's tough to guard," McGrady said. "He's big and strong. He works you down on that post. He knows how to use his body."
Artest stripped the ball from Chuck Hayes on a drive, but then lost the ball in a crowd on the final possession of regulation.
"Stuff like that doesn't happen often," Artest said. "Unfortunately, it happened at that time."
The Kings had just one turnover and shot 53 percent in the first 18 minutes of the game to build an 11-point lead.
Artest, guarded mostly by McGrady, hit five of his first eight shots and had 14 points in the first 1 1/2 quarters.
The Rockets finished the opening half with a 9-1 run to take a 54-51 lead to the break.
The Kings answered with an 11-0 burst early in the third quarter, spurred by 3s by Artest and Mike Bibby.
Artest scored 12 points in the third quarter and the Kings led 80-77 heading to the fourth.
Artest has scored 20 or more points in eight of his last nine games. ... The Rockets are 13-1 when they reach 100 points at home this season. ... Rockets C Dikembe Mutombo left the game late in the first half with a cut over his left eye. He got three stitches at halftime and started the second half. ... Kings center Brad Miller missed his third straight game with plantar fasciitis in his left foot.