The Raptors, seeking a first title, had led the seven-match series 3-1, an advantage that has only been overturned once in Finals history.
Stephen Curry scored 31 points for the Warriors, who lost the returning Kevin Durant to injury in the second quarter.
The Raptors have a second chance to clinch the title in Oakland on Friday.
Game seven, if required, will be back in Toronto on Sunday.
Point guard Curry, 31, described Monday's game as "do or die", adding: "It wasn't pretty in the second half but we just made the shots."
The relief was tempered, however, by the loss of Durant, who had just returned to the court from a calf problem after missing nine play-off games, and suffered a right Achilles tendon injury that left him unable to continue.
The 30-year-old, who was named 2017 and 2018 NBA Most Valuable Player and is Golden State's top play-off scorer with 34.2 points a game, left the venue on crutches and will have a scan.
"On the one hand I'm so proud of them, just the amazing heart and grit they showed, and on the other I'm just devastated for Kevin," Warriors coach Steve Kerr said.
"So it's a bizarre feeling we all have right now - an incredible win and a horrible loss at the same time."
Kawhi Leonard's 26 points for the Raptors were not enough in the fifth game of the NBA Finals
The Warriors have won three titles in the past four seasons - their loss to the Cleveland Cavaliers in 2016 is the only occasion a team has given up a 3-1 lead in Finals, which began in 1947.
And that stat is sure to give the Raptors hope of making history on Friday night after seeing their advantage reduced to 3-2 with a turnaround late in the fourth quarter.
Kawhi Leonard top-scored for Toronto with 26 points, including a back-to-back three-pointer, to give his side a lead of six (103-97) with just over three minutes remaining in the game.
The Raptors had, however, trailed by 14 in the third quarter and head coach Nick Nurse said: "In this day and age, up six with three minutes to go doesn't mean a whole lot.
"I felt good at that point. We just needed to make a couple more plays."
But Thompson and Curry each sank three-pointers to haul Golden State back into the game in the fourth and the latter scored another to keep them ahead with less than a minute on the clock.
After a Kyle Lowry score, the Raptors had one last opportunity to steal the title but a superb Draymond Green block denied Lowry a three-pointer on the buzzer.
Kerr added: "Our defence was bending down the stretch but we didn't break and the last stop was tremendous."