The Magic held the lead through much of the fourth quarter before a rally keyed by Tyreke Evans, who finished with 32 points for Memphis, tied the score at 97-all with 1:45 left on a basket by Marc Gasol.
However, a 3-pointer from Gordon with 52 seconds remaining put the Magic ahead for good.
Gasol ended the night with 22 points and nine rebounds. James Ennis III had 14 points and Brooks finished with 12.
Memphis played without starting point guard Mike Conley, who is nursing a sore left achilles.
Orlando, which dealt with a double-digit deficit in the first half, used balanced scoring in the third quarter to carry an 81-75 lead into the fourth. After the opening minutes of the fourth, the Magic’s lead never reached more than five down the stretch.
The Grizzlies could only overtake the Magic once – when Gasol scored with 1:04 left for a 99-97 lead.
Gordon’s 3-pointer put Orlando ahead for good.