BOSTON — The NBA’s most-decorated team avoided the biggest playoff collapse in league history and earned a chance to hang an unprecedented 18th championship banner from the rafters.

Paul Pierce had 31 points and 13 rebounds, and little-used backup Nate Robinson gave the Celtics a boost with 13 second-quarter points Friday night as Boston beat the Orlando Magic 96-84, earning a chance to play for a second NBA title in three years.

“Obviously, one (title) is special,” Celtics Coach Doc Rivers said, acknowledging that it’s not enough to rank among the great teams in franchise history. “The other groups have a couple and we would love to join that club. No one can ever take away that first one, but we want to join the other club, too.”

The finals will begin Thursday in Los Angeles or Phoenix.

The Lakers lead the Western Conference finals 3-2, and a victory over the Suns in Game 6 tonight would set up the cross-coast rivals for a rematch of the 2008 finals, and 10 other championship series from 1959-87.

“We got back to moving the ball, playing good defense, not allowing them to shoot the 3-point shot. That was the key,” Pierce said.

The Boston fans have been chanting “Beat L.A.!” since Game 3, when the Celtics cruised to a 3-0 lead in the best-of-seven Eastern Conference finals. Orlando won the next two games and threatened to become the first team in the NBA, but the second in Boston this month, to come back from a 3-0 deficit in a playoff series.

The Bruins opened a 3-0 lead against Philadelphia in the NHL’s Eastern Conference semifinals before the Flyers rallied to win — in the same building.

The Magic, who dressed in the same locker room where the Flyers celebrated, couldn’t match it, or even force the series back to Orlando for a Game 7.

“This starting five has never lost a series, ever,” Rivers said, alluding to the injury that kept Kevin Garnett out for the postseason last year and kept the new Big Three from defending its ’08 title. “We believed that coming into the season, and we just kept believing.”

Dwight Howard had 28 points and 12 rebounds as the defending East champions failed to get back to the finals. Vince Carter scored 17 points, and Jameer Nelson finished with 11 points and four assists as he was outplayed by Boston’s starting point guard, Rajon Rondo, and Robinson, his backup.

Reporters and fans snickered when Rivers said last month that Robinson, who struggled to get playing time and contributed little since coming at the trade deadline, would “win us a playoff game.”

But Robinson came off the bench at the start of the second quarter, when Boston led 30-19, and hit 3-pointers 1:30 apart to help stretch the lead to 15.

“You know, he really won this game for us because the game was in the mix to go either direction and he really gave us a spark,” Pierce said of Robinson. “That’s really growing up, really growing into a man tonight.”

The free throws gave Boston a 21-point lead, its biggest of the first half.

“Nate Robinson was huge in the first half,” Magic Coach Stan Van Gundy said. “That was a huge, huge lift for them.”

Orlando cut it to 13 points at halftime, but the Celtics scored 11 of the first 13 points in the third quarter and never led by fewer than 14 in the fourth until the final minute.

that point, the Celtics were dancing on the sidelines, wearing the Eastern Conference championship hats and T-shirts.

Ray Allen scored 20 points, and Rondo had 14 points and six assists. Glen Davis returned just two days after a scary concussion left him staggering around the court in Game 5 and scored six points with seven rebounds in 18 minutes. He entered to a standing ovation and left to another.

The Celtics followed a first-round win over the Miami Heat by eliminating LeBron James and the top-seeded Cleveland Cavaliers, then the Magic.

“They beat two very good teams, and made us look like we weren’t very good teams,” Van Gundy said.

“When you go through two series like that, I think you have to be fair and say a lot has to do with them.”