Carmelo Anthony scores 21 points in New York’s 88-80 win over Boston on Friday night. The Knicks advance to face the Indiana Pacers. (Jim Rogash/Getty Images)

With 18 seconds remaining in the New York Knicks’ series-clinching 88-80 victory over Boston in Game 6 on Friday night, Celtics Coach Doc Rivers pulled Kevin Garnett from the game, allowing fans at TD Garden to offer their appreciation for the final time this season and possibly the final time in Garnett’s legendary career.

Garnett walked directly toward Rivers, hugged him, slapped him on the chest, told him he loved him and then embraced him again. Garnett slapped five with his teammates along the bench, then grabbed Paul Pierce and tapped his side two times as the duo lost in the first round for the first time since they joined forces six years ago.

They didn’t bother sticking around to shake hands with Carmelo Anthony and the jubilant Knicks, who ended 13 years of futility by finally getting out of the first round. New York will host Indiana in Game 1 of the Eastern Conference semifinals on Sunday.

For the Knicks, the game had the feel of an exciting beginning to a postseason in which they could be around for a while. For the Celtics, the game had a feel of finality for an era in which Rivers, Pierce and Garnett brought the Celtics back to relevance as NBA champions and perennial contenders.

The Knicks did away with the wardrobe gimmicks, unnecessary trash talk and over-reliance on Anthony to build a 26-point lead in the fourth quarter and then withstood a 26-4 run from the pesky and prideful Celtics. Anthony scored a team-high 21 points, including the decisive, crowd-silencing baskets, and escaped the first round for just the second time in his career and first time as a member of the Knicks.

“It’s a big relief for myself, for us as a team, for the organization to make that next step, which is getting out of the first round,” said Anthony, who was swept by the Celtics two years ago. “It’s something that I’ve been looking forward to since I came here to New York, something that the organization’s been looking forward to, something that the city of New York been looking forward to. We was able to accomplish that.”

Knicks forward Iman Shumpert (17 points) had a putback dunk that gave the Knicks a 75-49 lead with 9 minutes 49 seconds remaining. But before New York started making plans for the second round, Avery Bradley and Jeff Green — not Pierce and Garnett — led an improbable rally.

Bradley stole the ball from Anthony and dunked to bring Boston within 79-75 with 3:32 left. Anthony answered with a pull-up jumper over Brandon Bass, then buried a three-pointer.

“I’m looking for a big picture and I’m only in this for one thing, and that’s to try and win an NBA title and we made a major step, but we’ve got a long way to go,” Knicks Coach Mike Woodson said.

Garnett will turn 37 this month and has been rumored to be leaning toward retirement. The Celtics also have a team option on Pierce’s $15.3 million salary next season and can buy him out for just $5 million to start anew in 2013-14.

Celtics President Danny Ainge said this week that he faces he a “very hard” decision with regards to Pierce, who sits above Larry Bird as the franchise’s second all-time leading scorer (John Havlicek is first) and has spent his entire 15-year career in Boston.

The Celtics played a video tribute to Pierce and Garnett during the first half that concluded with the words, “Let’s make history.” But the history may have already been made. Ray Allen left for Miami last offseason and Rajon Rondo has been out since tearing the anterior cruciate ligament in his right knee in January, leaving the duo as the last pieces from the 2008 championship team.

Garnett and Pierce helped carry the Celtics to a stunning victory in Game 5 at Madison Square Garden, where the Knicks had arrived wearing all black is if they were preparing to attend a funeral. The move backfired, and Knicks reserve J.R. Smith said that his team was “buried” instead after it suffered its second straight defeat.

That loss also opened up some old wounds for fans in New York, who had to endure watching the Yankees become the first Major League Baseball team to blow a 3-0 lead to the Boston Red Sox in the 2004 American League Championship Series. During a pre-game video, the Celtics got fans excited by posting, “0-3 is insurmountable. Unless you’re from Boston.”

But the Celtics had to overcome more than just a series deficit; they also had a limited roster with their most reliable players — with the exception of Green — also being the oldest. And, with only one day of rest, fatigue and excess mileage began to show on Pierce, who made his first shot, then missed his next nine. He finished with 14 points on 4 of 18 shooting in 44 minutes and left meekly with 27 seconds remaining as many in the stands didn’t realize that his night was done.

“I don’t think the fans knew,” Rivers said of the tepid applause for Pierce. “He’s one of the greatest Celtics to ever play. . . . I hope he comes back. I just don’t know right now.”

Garnett fought through with dogged determination, scoring 15 points with 10 rebounds.

“I really didn’t want him to go out that way, on our court,” Rivers said. “I didn’t want him to go out that way, but he is a winner. The best that I’ve seen.”