NEW YORK — When Mariano Rivera came out of the bullpen to pitch the eighth inning of the 84th All-Star Game on Tuesday night, his American League teammates stayed next to the dugout, applauding.

They waited, leaving the great Yankees pitcher on the field alone to soak up the applause from the crowd of 45,186. Rivera is set to retire after 19 seasons in the game, universally respected for his accomplishments on the field and elegant comportment off it.

Perez was born in 1990, the same year the Yankees signed Rivera out of Panama.

The historic moment was part of a nearly flawless performance by 10 American League pitchers in a 3-0 victory against the National League.

The National League was held to three hits and a walk.

American League manager Jim Leyland used Joe Nathan to close the game instead of Rivera. After promising on Monday that Rivera would pitch, Leyland used him in the eighth inning to make sure.

“I don’t really have any words to describe how I felt,” said Red Sox righthander Clay Buchholz. “It was definitely something special.”

Rivera won the Ted Williams Award as the game’s most valuable player, the first pitcher to be so honored since Pedro Martinez in 1999. At 43, he also is the oldest player to win.

“I wanted to come to the game and since this will be my last one, I wanted to enjoy and be able to pitch for the last time in the All-Star Game,” Rivera said. “The rest was indescribable.”

Red Sox designated hitter David Ortiz was 0 for 2 in the game. He flied to center field in the second inning and grounded into a double play to end the fourth inning.

Pedroia was 0 for 2. He popped to right field and struck out looking.

The Red Sox players had little impact on the game. But the Sox could benefit from the result of the game. The American League champions will now have homefield advantage in the World Series.

“It’s pretty important to the team that’s going to be in the World Series. Hopefully it’s our team. It’s good to win that game,” Pedroia said.

The AL snapped a three-game losing streak in the game. The NL leads the series, 43-39-2.

Yankees fans didn’t like the first inning of the game very much. Matt Harvey of the Mets drilled Robinson Cano in the right knee with a 96-mile-per-hour fastball.

Cano was attended to by a trainer and went to first base. But he came out of the game after Miguel Cabrera struck out and was replaced by Pedroia.

“I was in panic mode,” Pedroia said. “Just ran out there and here we go. But it was a good time.”

The loss of Cano would have devastated the already injury-riddled Yankees. But X-rays were negative and Cano has what was described as a bruise of his quadriceps.

“In the beginning it was a little tight. I didn’t want to aggravate it by trying to play through that situation,” Cano said. “Thank God it’s nothing bad. They said just put ice on it for a few days. I’m walking fine. It’s not pain; just tight a little bit.”

The Red Sox host a three-game series against the Yankees starting on Friday. Cano believes he will be able to play.

“Hopefully, yeah,” he said.

Harvey tapped his chest to acknowledge his mistake. Cano took no offense from the pitch.

“I know he doesn’t want to hit anybody, but it’s part of the game. What else can you do?” Cano said.

Said Harvey: “Obviously that was the last thing I wanted to do was go out there and possibly injure somebody. I think he understood it wasn’t intentional.”

The 24-year-old Harvey was the first pitcher from the host team to start the All-Star Game since Roger Clemens of the Astros in 2004. He was the youngest All-Star starter since Dwight Gooden of the Mets started the 1988 game at the age of 23.

“It was so much fun,” Harvey said. “It was a tremendous honor and something I was thankful for. This whole experience has been breathtaking.”

The American League took a 1-0 lead in the fourth, snapping a streak of 17 consecutive innings without scoring in the game.

Facing Patrick Corbin of the Diamondbacks, Cabrera doubled to the gap in right and took third when Chris Davis singled to left. Jose Bautista’s sacrifice fly to center scored Cabrera.

Cliff Lee of the Phillies gave up a run in the fifth inning. Adam Jones doubled to left field and moved up when Joe Mauer singled to left. J.J. Hardy drove in a run when he grounded into a force at second base.

American League pitching dominated the early innings. Tigers star Max Scherzer retired the side in order before Chris Sale of the White Sox, who got the win, went two perfect innings. The pitchers who followed held the NL down.

Jason Kipnis had an RBI double in the eighth inning. That set the stage for Rivera to come in.

“I don’t think anybody will forget it,” Buchholz said. “It was a great moment for baseball.”