The Grizzlies finished the game with a 13-1 run during the final four minutes to erase a 104-96 deficit.
Memphis improved its record to 17-16, the first time it has been above .500 this season.
Zach Randolph also scored 27 points for Memphis, which has won four consecutive games and seven of its past eight. Mayo hit 10 of 18 shots, including four 3-pointers. Randolph grabbed a game-high 14 rebounds.
Brandon Roy hit 9 of 18 shots and scored 27 points to lead Portland (22-15). Each of the Blazers' five starters scored in double figures, including Martell Webster, who hit five 3-pointers and scored 21 points.
Portland shot 61 percent (25 of 41) from the field during the first half, but had just a 58-57 halftime lead. Memphis also shot well, hitting 55 percent (22 of 40).
Memphis went on a big run during the third quarter. Gasol scored six points during an 11-0 run to stake the Grizzlies to an 80-73 lead. Memphis carried an 87-79 lead into the fourth quarter.
Portland made an immediate push, outscoring Memphis 12-2 to start the fourth quarter to take a 91-89 lead with 8:35 remaining. The Blazers built an eight-point lead, but were unable to hold it when Memphis scored nine unanswered points and took a 105-104 lead on Mayo's free throw with 21 seconds remaining.
Jerryd Bayless had a chance to tie the game at 106-106 with four seconds remaining, but he missed the first of two free throws.
Notes: Memphis is the only team in the NBA with two players averaging more than 20 points a game in Gay (20.8) and Randolph (20.2). ... LaMarcus Aldridge returned to Portland's lineup after missing the past two games with a left ankle sprain. He scored 11 points. ... Memphis was 5-10 and losers of eight consecutive games when it beat Portland 106-96 on Nov. 25. Since that game, the Grizzlies are 12-6. Memphis is averaging 112.9 points during its past eight games. ... Gasol is second in the NBA in field-goal percentage at .620.
Source: AP News