The Celtics made up a 16-point deficit in the third period to move in front by three, but Toronto then rebounded with a 13-4 surge that featured five points from Gay. His turnaround jumper with 4:28 to play gave the Raptors an 84-78 lead and Toronto went on to build as much as a 10-point advantage down the stretch.
Gay scored 19 points and grabbed eight rebounds to lead Toronto, which missed the playoffs by four games last season.
Amir Johnson and DeMar DeRozan both had 11.
Jeff Green, beginning his second full season with Boston, made half his 16 field goal attempts and scored 25 points.
The game marked the NBA coaching debut of Boston's Brad Stevens, who came to the Celtics after leading Butler to a 166-49 record and two appearances in the NCAA title game.