The young Toronto Raptors arrived in Miami on a high after knocking off the Lakers. For almost four quarters, it appeared Canada’s team would do the same to the defending champions.

Then overtime came.

The Heat scored 11 consecutive points in the extra period in a 123-116 overtime victory at AmericanAirlines Arena on Wednesday. Coincidentally, it was the Heat’s first game since defeating the Lakers last Thursday.

The Heat (27-12) has won three games in a row after a six-game stretch that featured just two victories.

Overtime allowed LeBron James to record his second triple-double of the season and 34th of his career. He finished with 31 points, 11 assists and 10 rebounds. James pulled down his final rebound of the game on the last possession. He had five rebounds in the five-minute overtime period.

“We played good basketball,” James said. “Not for 53 minutes tonight, but we played some really good basketball. We continued to share the ball, we continued to trust and we rebounded at a high clip.”

Toronto’s Alan Anderson began the extra period with a three-pointer and then put the Raptors (15-27) ahead by five with a layup. From there, the visitor’s found scoring difficult. The Heat finished the game with a 13-2 run.

Led by James, Dwyane Wade, and Ray Allen, the Heat blew the game open with its only dominant spurt of the night. Allen started the comeback with a three-pointer and then ended all the suspense with another minutes later.

Allen’s second three-pointer of the overtime run gave the Heat a 120-114 lead with 59.3 left.

“It’s pretty obvious why we went after him over the offseason,” Heat coach Erik Spoelstra said. “It doesn’t matter what kind of game he has had going into clutch time.”

Wade led the Heat with six points in overtime and finished with 35 points, going 13 of 19 from the field. He scored 25 points in the second half and overtime.

“Had to get those lungs back,” said Wade, who added that his knee finally feels like it’s returning to normal after offseason surgery. At the beginning of the season, Wade said the knee wouldn’t be fully healed until after the All-Star break.

“[Wade] made a lot of plays for us,” Spoelstra said. “He made it look easy, but he was in attack mode. I think he played his best, most active ball at the end. When guys started to get fatigued, he hit another gear.”

Wade’s assist on Allen’s first three-pointer of overtime sparked the rally. Wade finished the game with seven assists.

“He was able to get into the paint and find Ray, not many people can make that play,” Spoelstra sad.

The Heat trailed 57-50 at halftime, allowing the Raptors to shoot 57.5 percent from the field. At one point in the first half, Miami had six turnovers before the Raptors recorded their first. The Raptors led by as many as 15 points in the first half.

“It was set up to be an excuse game,” Spoelstra said. “Hopefully the second half was more indicative of how we’re playing right now.”

The fourth quarter featured three lead changes and five ties. It was tied at 109 at the end of regulation after James missed a potential game-winner at the buzzer. As he has done throughout the season, Allen once again shot the Heat back in the game with his three-point shooting. He had 11 points in the fourth quarter and OT.

In one of his best games in some time, Chris Bosh had 12 points and 12 rebounds. It was his 10th double-double of the season. The Heat outrebounded the Raptors 53-29.

Turnovers were a problem for the Heat throughout. James tossed a cross-court pass into the second row with 36 seconds left in regulation that nearly cost the Heat the game.

After playing from behind throughout, the Heat tied the score with 4:16 left in the third quarter on an alley-oop from Wade to James. Miami then forced a 24-second violation and James returned the favor on the Heat’s next possession, finding Wade inside for an easy layup. It was the Heat’s first lead since early in the first quarter.