TORONTO — The Boston Celtics are playing tough defense, as usual. Just not for the entire game, and it’s costing them.

Amir Johnson made two free throws with 2.7 seconds left, Andrea Bargnani scored 29 points and the Toronto Raptors snapped an eight-game losing streak to the Celtics with a 102-101 victory Sunday.

Paul Pierce’s shot bounced off the rim as the buzzer sounded, giving Toronto its first victory against Boston since a 114-112 road win on Jan. 23, 2008.

Boston, which lost 89-84 at home to Oklahoma City on Friday, suffered consecutive defeats for the first time this season.

“We can’t just show up. We’ve got to play some D,” a frustrated Kevin Garnett said. “These teams we’re playing against are very high-caliber offense teams. We know what they are. On paper they might not be whatever but as far as talent, this league has a lot of talent and you’ve got to respect that.”

Nate Robinson led Boston with a season-high 22 points, Pierce and Ray Allen each had 19 and Garnett and Glenn Davis both scored 12.

Boston’s Rajon Rondo, who left Friday’s game with a strained left hamstring, was held out of the lineup. His replacement was Robinson, who made an immediate impact by scoring 16 points in the first quarter, including three 3-pointers, as the Celtics built a 31-23 lead.

But Pierce said Boston lacked the proper focus in the second quarter, just like in its loss to the Thunder.

Toronto had won just one of its previous 12 against Boston, including six straight losses at home, but turned this one around with a 38-point second quarter, the biggest output by a Celtics opponent in any quarter this season.

“We may be the worst second-quarter team in all of basketball,” Pierce said. “We come out, get these leads and then we give them right away in the second quarter. We’ve got to do a better job and be more consistent throughout the game, quarter by quarter.”

With seconds left, Pierce was whistled for a foul on Johnson, who made both to give the Raptors a 102-101 lead.

Rivers didn’t like that call either, but refused to criticize the officials when asked whether he thought it should have been a shooting foul.

“You answer that,” Boston Coach Doc Rivers said. “I need my money, I have four kids. I’ll let you answer that. I didn’t see anything.”