After spending the entire offseason up to this point in limbo, Lorenzo Cain finally knows where he’ll play in 2018 and beyond.

The former Royals center fielder reportedly agreed on Thursday to a five-year deal with the Milwaukee Brewers, the team that drafted him in 2004 before shipping him to Kansas City along with Alcides Escobar in December 2010.

The news, first reported by The Athletic’s Ken Rosenthal, came soon after the Brewers agreed to send four prospects to the Marlins for outfielder Christian Yelich.

Cain’s five-year contract is worth $80 million, according to ESPN’s Jerry Crasnick.

The Brewers had not announced the deal by 8 p.m. Thursday, but various reports indicated that Cain passed a physical examination.

The Royals, unwilling to offer Cain a hefty contract, will get a compensatory pick between the first round and competitive balance round A of the baseball draft, according to MLB.com.

Cain was part of the 2010 trade that sent Cy Young winner Zack Greinke to the Brewers and gave the Royals, in Cain, the player who turned out to be the American League Championship Series MVP of their first pennant-winning team (2014) in nearly 30 years.

Cain, like the Royals, burst onto the national scene that 2014 season. He slashed .533/.588/.667 (batting average/on-base percentage/slugging percentage) during the ALCS, but found a near permanent place in national headlines by flashing his glove throughout the postseason. A highlight reel of his defensive gems shows a handful of diving catches, including when he trapped a line drive off the bat of the Giants’ Buster Posey as Cain fell onto his knees and slid a few feet across the grass in Game 3 of the 2014 World Series.

An All-Star in 2015, Cain scored the go-ahead run that allowed the Royals to win a second straight American League pennant. Cain finished third in American League MVP voting, when the Royals won the franchise’s second World Series Championship.

After a 2016 campaign hampered by injuries, Cain played in a career-high 155 games in 2017 and hit .300 with 27 doubles, five triples, 15 home runs and 49 RBIs. He also went 26 of 28 on the basepaths, bumping his career stolen-base total to 127.

Cain is one of three players with an on-base percentage above .350 and 90 or more stolen bases since 2014, per a tweet by the STATS company. His .352 OBP and 96 stolen bases trail the Astros’ Jose Altuve (.384, 156) and the Rockies’ Charlie Blackmon (.366, 102) in that span.

In the same span, Cain is ninth in the American League in Wins Above Replacement (17.9) in the Fangraphs version of the stat.

Despite his age — he turns 32 in April — Cain is still regarded as an excellent defender and was a Gold Glove finalist last season. Cain is 14th among active players with a 12.1 defensive WAR, according to Baseball Reference. His 56 defensive runs saved since 2014 rank sixth among outfielders.

Cain is the first of the Royals’ batch of high-profile free agents this offseason, which includes Eric Hosmer and Mike Moustakas, to agree to terms with a club.

In a late-season interview, Cain told The Star’s Rustin Dodd he had thought he would be the Brewers’ center fielder of the future before he was traded in 2010.

Eight years later, that dream will bear fruit.

“They all know where I stand as far as coming back to KC,” Cain said then. “They know I would love to come back here. I said it in the spring, and I’ll say it again now. But at the same time, everyone has to do what’s best for themselves. No one knows what’s going to happen.

“The ride I’ve been on, the ride we’ve been on. It’s been amazing.”