Mookie Betts singled, bringing Perez to the plate. Perez, who made the last out of the 2014 World Series with the tying run at third in Game 7, has starred in the spotlight since. He was the most valuable player of last year’s World Series, and this time he pulled a fastball from Cueto down the left-field line for a two-run homer.

Hosmer drove in the A.L.’s last run when his hard single handcuffed Bryant at third in the third inning. He is the first Royal to be an All-Star M.V.P. since Bo Jackson in 1989, and he was thrilled to share the stage with Perez.

“Couldn’t have worked out any better,” Hosmer said. “Salvy and I go way back. We have been playing this game together for a long time, and to share that experience and have the games we did tonight was really special.”

Edwin Encarnacion scored on Hosmer’s single after pinch-running for David Ortiz, who walked against Jose Fernandez in his final plate appearance. Ortiz, who grounded out to first base off Cueto in the first, left the field to cheers and hugs from his teammates.

Ortiz, who plans to retire after the season, had expected Fernandez to give him a hero’s exit, but Fernandez started him with an 80 mile-an-hour pitch — effectively a batting-practice fastball, well out of the strike zone — and scrambled the plan.

“I was supposed to hit a home run in my second at-bat,” Ortiz said. “My boy told me he was going to throw me nothing but fastballs, and then the first pitch was a changeup! I was like, ‘Wait, I thought you told me you were gonna throw nothing but fastballs — what happened?’”

Ortiz gave the team a pep talk before the game — at the urging, he said, of a Major League Baseball official — and said he was touched by the adoration of players like Bryant, who called Ortiz his hero.