BOSTON (AP) -- Paul Pierce's shot rimmed out in the final seconds of overtime, and Pau Gasol knew the game wasn't over yet. The ball bounced to Ray Allen, who gave it a two-handed push back toward the basket.
"That shot that Ray Allen took was good, in my opinion," Los Angeles Lakers coach Mike Brown said. "But Pau did not stop playing until he heard the horn, and he came up with the big block."
Gasol had 25 points, 14 rebounds and a key block of Allen's putback attempt at the overtime buzzer Thursday night and the Lakers held on to beat the Celtics 88-87. Kobe Bryant scored 27 points and Andrew Bynum had 16 points and 17 boards for Los Angeles, which snapped a two-game losing streak.
Allen scored 22 points and Kevin Garnett had 12 points and 12 rebounds for Boston, which had won five in a row and nine of its previous 10 games. But Garnett was 6 for 23 from the field and Pierce was 7 for 18, including a clean-look jumper at the end of overtime.
It went right to Allen. He tried to push the rebound in, but Gasol got his fingertips on it and it floated away as the buzzer sounded.
"I was in the perfect position," Allen said, "and he came out of nowhere."
Gasol also made a smart play in the fourth quarter, when the 6-foot-11 Garnett lined up for a jump ball against 6-foot-1 Derek Fisher. Gasol read the play and the Lakers wound up with the ball.
But the block at the end of the game clinched it.
"I've been in situations before in my career where you freeze ... catch yourself looking at the ball and end up losing the game," Gasol said.
The Lakers had lost six of their last seven games on the road.
But a trip to Boston to play the rival Celtics was just what they needed.
Both teams shot under 40 percent, and they each missed twice to start the overtime before Bryant sank a jumper that gave the Lakers an 84-82 lead with 3:30 left. Allen missed, then Steve Blake made a jumper to give the Lakers a four-point lead -- their biggest of the game.
Pierce made a jumper and, after Gasol missed, Pierce hit a 3-pointer over Metta World Peace to make it 87-86 Boston. Bryant missed, but Bynum tipped it in with 1:30 left to give L.A. the lead, and it held up.
"I thought this was an awful game," Celtics coach Doc Rivers said. "If we had won, it would have been an awful game that we won. Give them credit: A lot of that was defense. But I thought a lot of it was self-inflicted."
Pierce finished with 18 points, nine rebounds and seven assists. He had the ball in his hands with a chance to win the game at the end of regulation and again in overtime -- the first time he picked up his dribble and got trapped with Allen open in the corner, and the second time his shot rimmed out.
"One of them I didn't make the pass," he said, "the other I missed the shot."
Bynum converted a three-point play to give the Lakers an 80-79 lead with 2:39 left in regulation, and it stayed that way through several trips down the floor before the Celtics called a timeout with 1:16 left. After the inbounds pass, Allen made a catch-and-shoot 3-pointer to put Boston into the lead.
World Peace, who hit the NBA title-clinching basket for the Lakers against Boston in 2010 back when he was known as Ron Artest, missed a 3. Garnett grabbed the rebound and the "Beat L.A.!" chants began in the TD Garden.
But Garnett missed a jumper and Gasol tipped in Bryant's miss to tie it 82-all. The Celtics had a chance to win it in regulation, but Pierce got trapped near midcourt and Pietrus was forced to fire up a no-chance 30-footer at the buzzer.
The Celtics led by nine points in the first quarter, but the Lakers erased the deficit in the second and briefly took a one-point lead at 38-37. Boston led 64-59 when Gasol converted a three-point play and Bryant made back-to-back jumpers to give Los Angeles a 66-64 lead.
Notes: Pierce was the only Celtic selected to the All-Star roster when the reserves were announced Thursday. ... Boston's Marquis Daniels played for the first time in four games because Sasha Pavlovic had a flare-up in a left wrist injury that he sustained in training camp. ... Bynum had nine points and nine rebounds in the first half. ... The AFC champion New England Patriots were well represented: Vince Wilfork, Rob Gronkowski and owner Robert Kraft were all at the game, fresh off Sunday's Super Bowl loss to the New York Giants. ... The teams meet again in Los Angeles on March 11. ... Garnett took a season-high 23 shots.