But any joy from the victory was dimmed by a right Achilles injury to Kevin Durant only 12 minutes into his first game after being sidelined for a month by a right calf injury, AFP reported.
Curry scored 31 points while Thompson added 26 as the Warriors pulled within 3-2 in the best-of-seven championship series, forcing a sixth game Thursday at Oakland, California, with game seven if needed in Toronto on Sunday.
"Do or die," Curry said.
"It wasn't pretty in the second half but we just made the shots."
Durant's long-awaited return ended with the All-Star forward being helped off the court.
"You could kind of just feel the life just go right out of us," Warriors forward Draymond Green said.
"But to Steph's credit, he rallied the troops.
"He talked to everybody, went around the huddle and just told everybody to stay locked in and do this for Kevin. And I think we did a good job of coming together."
Durant, the 2017 and 2018 NBA Finals Most valuable Player, departed the arena on crutches but became an inspiration to his teammates.
"We do it for Kevin," Thompson said.
"He wants us to compete at the highest level and we'll think of him every time we step on the hardwood."
Durant breathed life into Golden State's title quest, Curry said.
"We understand the moment and I think we can rally, considering how the second half went," Curry said.
Durant, Golden State's top playoff scorer with 34.2 points a game, will have an MRI on Tuesday.
"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."
The Warriors seek their fourth title in five seasons while the Raptors suffered an agonizing near-miss in their bid for the first title in their 24-season history.
History remains on the Raptors' side. Only once in 34 prior situations has a team led the NBA Finals 3-1 and lost the title, that being in 2016 when LeBron James-led Cleveland rallied to defeat Golden State.
Needed a couple plays
Kawhi Leonard, who led Toronto with 26 points, sank a back-to-back three-pointer and jumper to give the Raptors, who trailed by 14 points in the third quarter, their largest lead at 103-97 with 3:28 remaining.
"In this day and age, up six with three minutes to go, doesn't mean a whole lot," Raptors coach Nick Nurse said.
"I felt good at that point. Just needed to make a couple more plays."
Golden State answered with Thompson and Curry sinking three-pointers and Thompson nailing another that put Golden State ahead to stay at 106-103 with 57 seconds to play.
Kyle Lowry cut the lead to the final margin with 30 seconds remaining and, after Golden State's DeMarcus Cousins was whistled for a foul trying to set a screen, the Raptors had one last chance to swipe the title.
But the Warriors double-teamed Leonard and Green blocked a Lowry corner three-point shot at the buzzer.
'Greatest' Warriors win
"It has got to be the greatest," Green said when asked to compare the win to others in Golden State's history.
"Down six with a couple minutes to go in an elimination for these guys to win a championship, we could have thrown in the towel. We could have folded, but we didn't."
Durant had missed nine playoff games but he briefly made the Warriors look like the team that dominated the past two NBA Finals.
Disaster struck 2:14 into the second quarter when Durant planted his right foot and pulled up, then sat on the court and grabbed his leg. Durant was helped off the court, his dramatic comeback over far too soon.