Mayo had 19 of his game-high 33 points in the final period, but the victory went to the fifth-year veteran known as the Brazilian Blur and Phoenix as the Suns won 107-102 on Monday night.
Barbosa almost went shot-for-shot with the rookie in the fourth, scoring 16 of his team-high 27 points in the period, including the go-ahead 3-pointer with 43.8 seconds left.
"It was the first time that I was doing well and I felt like I could go to the basket and I could shoot," said Barbosa, whose season high had been 18 points Oct. 29 at San Antonio. "My teammates were helping me and the coach was helping me, too, and it was great."
Barbosa sank his second 3-pointer of the game to give Phoenix a 103-102 lead.
After a pair of Steve Nash free throws, Mayo missed a straightaway 3-pointer with 6.9 seconds to allow Phoenix to escape with its ninth straight win over Memphis.
"There was a critical possession where we had the scramble and we were looking for a foul but you can't count on that," said Grizzlies coach Marc Iavaroni. "You've got to just play."
"Mayo really tried to take the game over but our guys hung in there in the end and made some plays," said Suns coach Terry Porter.
"We know both of those guys [Mayo and Gay] are very explosive scorers," Porter said. "They can score just about any way you need them to score."
Phoenix had an 82-70 lead heading into the fourth quarter before Mayo single-handedly carried the Grizzlies within a basket. Mayo scored 11 straight points, including a 19-footer with 8:42 to play as Memphis pulled to 87-85.
"O.J. is a phenomenal player and he kept us in the game for a long stretch of time," Gay said. "He made the right decisions. When he should have passed he passed and when it was time to make the basket he made it."
The Suns stretched the lead back to six, 93-87, only to see the Grizzlies tie the game 94-94 on Gasol's three-point play with 4:22 to go. Hakim Warrick gave Memphis a 96-94 lead on a 22-foot bank shot with 3:48 left.
Barbosa put the Suns back ahead 100-98 on a 3-pointer from the right wing. Milicic tied the game with a layup with 2:12 left before Gay gave Memphis its final lead, 102-100, on a dunk off an offensive rebound with 1:30 remaining.
"They made some plays down the stretch," Mayo said. "Our team doesn't have a lot of years. We've got to work on finishing games down the stretch."
Barbosa scored 10 straight points in the third and fourth quarters for Phoenix, including the Suns' first eight in the fourth. He was the only Phoenix player to hit a field goal between Diaw's layup with 3:37 left in the third and Raja Bell's 3-pointer with 3:28 to go.
"We took our foot off the pedal a little bit," Bell said. "They have one of those teams where they're really talented across the board. If you give them an ounce of life that's all they need to get their confidence going and we gave them that."
Mayo had given the Grizzlies a 51-50 lead on a 3-pointer with 9:34 to go in the third quarter before the Suns pulled away.
Matt Barnes' 3-pointer started an 18-4 run over the next five minutes as Phoenix opened a 68-55 lead with 4:34 left in the period. Bell, Diaw and Nash also hit 3-pointers during the streak for the Suns, who finished 8-for-21 from beyond the arc.
Barbosa's layup with 54.5 seconds left gave the Suns their biggest lead, 82-65, and started his scoring streak.
Porter is 6-2 in his Suns career, the best start for a coach in franchise history. ... Bell missed the morning shootaround following the birth of his second child on Sunday. ... Barnes returned to the lineup after missing three games following the birth of two sons. ... Memphis had won four of five meetings before the current losing streak. The Grizzlies are 4-22 all-time in Phoenix and have not beaten the Suns in the Valley since November 16, 2005.