The Serbian sharpshooter buried a 22-foot jumper at the buzzer, lifting the New Orleans Hornets to a thrilling 132-130 double-overtime road victory over the Suns on Wednesday night.
"We had the game in our hands at the end of regulation and at the end of the first overtime, but we just couldn't finish," said Stojakovic, who ended up with 26 points. "I was very fortunate to make that shot."
Chris Paul had 42 points, nine assists and eight steals for the Hornets (33-15) who without flu-ridden centre Tyson Chandler snapped a three-game slide while improving to 3-0 against the Suns this season.
Jannero Pargo tallied 12 of his 22 points in the two overtimes while David West chipped in with 21 and 13 rebounds.
"Great game from Phoenix, they never quit," Paul said. "But Peja Stojakovic was the hero of the night. When the shot went in I just felt a sigh of relief."
Steve Nash led Phoenix (34-15) with 32 points and 12 assists while Amare Stoudemire added 26 points and a season-best 20 rebounds. Boris Diaw and Leandro Barbosa scored 22 points apiece.
Hours earlier, the Suns acquired 14-time All-Star centre Shaquille O'Neal from the Miami Heat for Shawn Marion and Marcus Banks in their quest to win a franchise-first NBA Championship.
"I'm ready to win a title, I've been preaching that for four years," Stoudemire said. "We're definitely excited about the situation. We tried to put it aside, but the Hornets played well."
With O'Neal watching his new teammates from a private box at the US Airways Centre, the Suns repeatedly battled back and knotted the game for the final time at 130-130 on Barbosa's three-pointer with 3.2 seconds left, setting the stage for Stojakovic's heroics.
Elsewhere: Detroit Pistons 100, Miami Heat 95 Rasheed Wallace collected 26 points with 10 rebounds, leading the hosting Pistons to their sixth straight victory. Dwyane Wade had 30 points and 12 assists for league-worst Miami (9-38) losers in 20 of its last 21 games.
Atlanta Hawks 98, LA Lakers 95 Joe Johnson scored 28 points, including four free throws in the final 23 seconds, as the Hawks contained Kobe Bryant and Spanish newcomer Pau Gasol for their third straight win.
Playing with a dislocated right pinkie finger, Bryant had just 11 points and Gasol finished with 12, in his second game as a Laker. Lamar Odom led the Lakers (31-17) with 19 points and 11 rebounds. Derek Fisher scored 17, but missed a potential game-tying three- pointer at the buzzer.
Dallas Mavericks 107, Milwaukee Bucks 96 Reigning league MVP Dirk Nowitzki had his first career triple- double with 29 points, 10 rebounds and 12 assists, carrying the Mavericks to their eighth consecutive home victory. Mo Williams scored a season-high 36 points for the Bucks (19-31) who without starters Michael Redd, Yi Jianlian and Bobby Simmons lost for the fourth time in the last five games.
Orlando Magic 100, New Jersey Nets 84 Dwight Howard had 21 points with 13 rebounds and the Magic sent the struggling Nets to their 13th loss in the last 16 games. Vince Carter paced the visiting Nets (20-29) with 18 points.
Indiana Pacers 103, New York Knicks 100 Kareem Rush scored 24 points and the visiting Pacers snapped a seven game slide by limiting the Knicks to three field goals in the final 8 1/2 minutes. Zach Randolph scored 26 points for the Knicks (14-35) losers of seven in a row.
San Antonio Spurs 85, Washington Wizards 77 Tim Duncan had 23 points with nine rebounds and visiting Spurs sent the short-handed Wizards to their season-high fifth straight loss. Antawn Jamison led the Wizards (24-24) with 18 points. Andray Blatche, filling in for All-Star forward Caron Butler (strained left hip flexor) had 16 points with a career-high 15 rebounds.
Boston Celtics 111, LA Clippers 100 Rajon Rondo scored a career-high 24 points, Ray Allen had 19 and the league-best Celtics (37-9) handed the Clippers their 10th road loss in the last 11 games even though All-Star forward Kevin Garnett (abdominal strain) missed his fifth straight game. Corey Maggette led the Clippers (15-31) with 33 points.
Utah Jazz 118, Denver Nuggets 115 (OT) Deron Williams scored 29 points, Kyle Korver had 27, including four free throws in the final 19 seconds of overtime, leading the visiting Jazz to its 10th consecutive victory. Allen Iverson had 34 points and Carmelo Anthony added 29 before fouling out late in the extra session for Denver (29-19) which had won its previous three games.
Portland Trail Blazers 100, Chicago Bulls 97 Brandon Roy scored 28 points, including the game-ending free throws with five tenths of a second left, and the Trail Blazers trimmed the visiting Bulls. Swiss Thabo Sefolosha and Argentine Andres Nocioni topped the Bulls (19-29) with 22 points apiece.
Seattle SuperSonics 105, Sacramento Kings 92 Earl Watson had his first career triple-double with 23 points, 10 rebounds and 10 assists, as the visiting Sonics snapped the Kings' four-game winning streak. Ron Artest led the Kings (22-25) with 20 points.
By Paul Levine, dpa