Brewers pitcher Josh Hader delivers in the eighth inning of Tuesday’s All-Star Game. (Patrick Smith/Getty Images)

Racist, homophobic and misogynistic tweets that Milwaukee Brewers reliever Josh Hader sent in 2011 and 2012 surfaced as he pitched in Tuesday night’s All-Star Game at Nationals Park, turning his appearance into an embarrassing stain for Hader and a public-relations nightmare for Major League Baseball.

After Hader surrendered a three-run homer in the eighth inning, several Twitter users — starting, it seems, with an account named MLB Insider Dinger — found and retweeted messages Hader sent as a 17-year-old. The tweets included numerous uses of the n-word and an allusion to “white power” next to an emoji of a closed fist. One tweet read only, “I hate gay people.” Another referenced wanting women only for sex, cooking and cleaning.

“It’s just something that happened,” Hader, a former All-Met from Old Mill who grew up in Anne Arundel County, said after the game. “I was 17 years old. As a child, I was immature. I obviously said some things that were inexcusable. That doesn’t reflect on who I am as a person today. That’s just what it is.”

On Wednesday, Major League Baseball announced it would require Hader to complete sensitivity training and participate in the league’s diversity and inclusion initiatives, calling his past tweets “unacceptable.” Brewers General Manager David Stearns called Hader’s tweets “inexcusable” in a statement and said the Brewers “do not believe that these posts are representative of his beliefs.” Neither the league nor the Brewers indicated Hader would face punishment. MLB Deputy Commissioner Dan Halem declined to comment Tuesday night.

Hader discovered that the tweets had surfaced after he exited the game. When he arrived in the locker room, “my phone was blowing up,” he said. As the game came to a close, several of Hader’s family members and friends milled outside the clubhouse, all of them wearing all-star jerseys with “Hader” across the back.

Hader, still in full uniform, motioned his wife inside to a lobby outside the locker room. As they talked, the rest of Hader’s party removed the jerseys and either changed out or reversed clothing with the player’s name on it.

When the National League clubhouse opened to media, Hader was standing alone at his locker, his blond hair pulled into a bun. Reporters surrounded him. A public-relations official asked reporters to wait. Another PR man said to the other: “Give it a second. We got a couple more [reporters] coming. We got a bunch more.”

Hader blamed the tweets on youth and immaturity and insisted they did not reflect his current beliefs.

“There’s no excuse for what was said,” he said. “I’m deeply sorry for what I’ve said and what’s been going on. That doesn’t reflect any of my beliefs now.”

How could the tweets have lived online for so long without Hader deleting them?

“No deletes,” he said. “Obviously, when you’re a kid, you just tweet what’s on your mind.”

Before the game ended, Hader had deleted his old tweets and locked his account. He said he would accept any suspension or punishment, with the caveat of his age at the time he sent the tweets.

“I’m ready for any consequences for what happened seven years ago,” he said.

“Like I said before, I was young, immature and stupid. There’s no excuses for what was said or what happened.”

Hader said he did not “vividly” recall sending any of the offensive messages. “That was seven years ago,” he said. “I don’t remember too far back then.”

Hader repeated his age and the time passed since the tweets. While he was nearly an adult when he sent them and not, as he called himself once, a “child” at the time, Hader insisted the tweets would not reflect on him.

“Not at all,” he said. “I was in high school. We’re still learning who we are in high school. You live and you learn. This mistake won’t happen again.”

After he spoke with reporters, Hader huddled over his phone with a PR representative as Brewers teammate Jesus Aguilar packed up at the locker next to him. Brewers outfielder Lorenzo Cain sat a few stalls down.

Hader walked over to Cain, slung his arm around him and whispered into Cain’s ear. Cain’s son chattered nearby. They talked for a bit, and then Hader walked away.

“I was just trying to understand the situation,” said Cain, who is black. “He’s young. We all say some crazy stuff when we’re young. That’s one reason why I don’t have social media, because things like this. You always get in trouble for things you said when you’re younger. We’ll move on it. The situation is what it is. I know Hader. He’s a great guy. I know he’s a great teammate. I’m fine. Everybody will be okay. We’ll move on from it.

“Yeah, I was surprised. When anybody does something like that, you’re always surprised. At the end of the day, you got to give people a second chance. And I understand you got to forgive people and move on from it. For me, it’s over and done with. He said it. It got out there. I’m moving on from it. Me, individually, anyway.”

When Hader finished speaking with Cain, Brewers outfielder Christian Yelich walked over to Hader and hugged him.

“I don’t know what he did or what happened,” Yelich said. “But the guy I know is a really great guy with a kind heart.”

Hader, a 24-year-old left-hander, has pitched to a 1.50 ERA in 48 innings this season, striking out 89 of the 177 batters he has faced.

Jorge Castillo and Chelsea Janes contributed.