It had never been so difficult for Mike Trout to arrive at the ballpark, get his mind and body ready, and perform at the level baseball fans have come to expect.

And still, nobody did it better in the American League.

Trout overcame injury and tragedy to win his third AL MVP award Thursday night, getting 17 of 30 first-place votes in balloting by the Baseball Writers’ Association of America. Alex Bregman of the Houston Astros was second, and that duo combined for all the first- and second-place votes. Trout also won the award in 2014 and ’16.

“This year was probably the toughest year,” Trout said.

Dodgers outfielder Cody Bellinger made it a Southern California sweep, beating out the Milwaukee Brewers’ Christian Yelich for the NL prize. Bellinger got 19 of 30 first-place votes, Yelich got 10, and Washington’s Anthony Rendon got one while finishing third. Yelich won the award last year.

Trout had season-ending foot surgery in September while the Angels languished to a fourth-place finish. The outfielder played just 134 games but still set a career high with 45 homers. He batted .291, led the majors with a .438 on-base percentage and drove in 104 runs.

The 28-year-old shined even following the death of close friend and teammate Tyler Skaggs on July 1. Trout smashed a 454-foot homer wearing Skaggs’ No. 45 in the team’s first game back, when LA pitchers threw a combined no-hitter.

After often deferring to veterans as a young star, Trout put himself into a leadership role following Skaggs’ death.

“It was my time,” Trout said, adding that “it was extremely tough mentally and emotionally for us at the end of the year.”

Trout is the 10th three-time MVP and joins an elite group: Barry Bonds, Yogi Berra, Roy Campanella, Joe DiMaggio, Jimmie Foxx, Mickey Mantle, Stan Musial, Albert Pujols, Alex Rodriguez and Mike Schmidt. Bonds is the only player with more than three MVPs — he won seven. Only Musial was younger when he won his third.

Trout also has a record-tying four second-place finishes. He’s been the winner or runner-up in seven of his eight full seasons.

Skaggs was found dead in his hotel room before the start of a series against the Texas Rangers. The Tarrant County Medical Examiner's Office said the 27-year-old died after choking on his vomit with a toxic mix of alcohol and the painkillers fentanyl and oxycodone in his body. MLB is cooperating with a federal investigation after Eric Kay, a 24-year employee of the Angels' PR department, told the Drug Enforcement Agency he had provided opioids to Skaggs and used them with the pitcher for years, according to ESPN.

Trout played through the pain of that loss and the lingering foot issue, which hampered him for about a month before he chose to have surgery. He learned he won the award while on his yearly hunting trip in Iowa, and he said he’ll begin lower-body workouts in conjunction with the Angels’ training staff when he returns.

The 24-year-old Bellinger and his loose, left-handed swing launched 47 home runs with a .305 average, 115 RBIs and a 1.035 OPS.

He was the best player on the NL’s top team in the regular season, propelling Los Angeles to 106 wins. He’s the 10th different Dodgers player to win MVP and first since Clayton Kershaw in 2014.

Bellinger teared up after learning he’d been chosen, saying it was the first time he had cried since the death of his first dog, Angel the golden retriever. He was especially emotional after hugging his father — former big leaguer Clay Bellinger.

“He was just there for me every single day,” Cody Bellinger said.

It was clear by midseason that Bellinger and Yelich were the favorites for the NL prize. Yelich had better offensive numbers, including a league-leading .329 average and a major league-best 1.100 OPS, but his season was cut short in September when he broke his right kneecap on a foul ball.

“I pretty much figured that once I got hurt, that was a wrap on that but I guess you never really know until the end. But that was my mindset. As soon as I got hurt, I figured all that MVP stuff went out the window,” Yelich said.

Said Bellinger: “I think he pushed me to be a better player.”

Advanced metrics showed both races to be tight. Bellinger and Yelich tied for the NL lead with 7.8 wins above replacement (WAR) as measured by Fangraphs, and Trout edged Bregman 8.6 to 8.5. Bregman topped Trout 8.4 to 8.3 by Baseball-Reference’s WAR, while Bellinger bested Yelich 9.0 to 7.1, mostly due to stronger defensive ratings.

Bellinger won the Gold Glove Award in right field but also played center and first base. He’s the first Dodgers position player to win MVP since Kirk Gibson in 1988.

“This award man, it just makes me so much hungrier to keep performing,” Bellinger said. “The feeing that you have, why would you ever not want to receive this? So I have to keep working hard at what I do and hopefully keep getting better.”