AUBURN HILLS, Mich. - For most of Saturday night, the Toronto Raptors played as though they were in a daze.

At the end of the evening, though, it was the Detroit Pistons who didn't know what to say.

Jerryd Bayless matched a career high with 31 points and Toronto pulled off the biggest comeback in franchise history, beating the Pistons 120-116 to end a four-game losing streak.

The Raptors trailed by 25 points midway through the third quarter and were still down 16 going into the fourth, but stormed back for just their third road win of the season.

"We just came together -- that's all I can say," said ex-Piston Amir Johnson. "We were shooting the ball well, but we were having problems on defence. We knew we had to start getting stops, and we stepped up."

Andrea Bargnani added 22 points, including a pair of key three-pointers in the fourth quarter, and Leandro Barbosa scored 20.

Previously, the biggest comeback by Toronto was a 22-point deficit against the Los Angeles Clippers on Nov. 13, 2009.

"I've never been in a game where we were shooting 60 per cent and we were down 20 points," Raptors coach Jay Triano said. "We knew we weren't having any problems scoring, but we had to take care of the ball and we had to box out. We did that a lot better in the second half."

The bizarre game even had a strange ending, as Ben Wallace flipped in a meaningless three-pointer -- his first in four seasons and just the fifth of his 15-year career. The shot gave Wallace a career-high 23 points and Rodney Stuckey a career-best 12 assists, but that wasn't any consolation to the Pistons.

"You look at the boxscore and we've got guys setting career and season highs all over the place, but the other team shot 63 per cent and won the game," Tayshaun Prince said. "We just self-destructed. I don't know how else to explain this."

The Pistons were coming off an 0-3 road trip and even a veteran like Prince couldn't say how this loss would affect the team.

"That's a good question, but I don't know what the carry-over from a game like this might be," he said. "I've never been a part of a game like this before."

Stuckey also had 23 points for the Pistons, while Wallace added 14 rebounds, five steals and four assists.

Toronto shot 65 per cent from the floor in the first half, but committed 14 turnovers that led to 29 Detroit points. Meanwhile, the Pistons turned the ball over only once on their way to a 72-53 lead.

"I don't know if our defence was that bad in the first half. We turned the ball over for 29 points and gave up another 20 second-chance points," Triano said. "That's not defence."

The Pistons led 89-64 with 5:51 left in the third. It was still a 22-point game with a minute to go in the quarter, but the Raptors finished the period with a 7-1 run.

"We gave them a lot of momentum when they got that little run at the end of the third," Pistons coach John Kuester said. "Momentum changed in an awful hurry in this game."

Bargnani's three-pointer pulled the Raptors within 106-98 with 8:18 to go, and Johnson followed with a three-point play.

The Raptors cut it to 110-107, and Bargnani tied it with another three with 2:05 left. After a Pistons miss, Bayless hit a three-pointer and then answered Wallace's putback to give Toronto a 115-112 lead with 49 seconds to go.

Stuckey made one of two free throws and Bayless did the same, leaving it a three-point game with 20 seconds left.

Prince threw away a lob on the ensuing inbounds play, and Bayless clinched the game from the line.

"We didn't want to get embarrassed, so we came to our senses out there," DeMar DeRozan said. "We got on a roll and we won the game. That's a solid win for this team."

NOTES: Each of the first two quarters ended with long three-pointers at the buzzer. Tracy McGrady's 60-footer at the end of the first was ruled to have been too late, but Barbosa's shot from just inside halfcourt counted to end the first half. ... Detroit's 72-point first half was its biggest since scoring 73 against Denver on March 18, 2008. ... Bayless also scored 31 points for Portland against San Antonio on Dec. 23, 2009.