– The Twins have landed Kenta Maeda after all.

The framework of a trade — after the teams and players involved survived the scrutiny of medical records — was finalized Sunday with the Dodgers sending veteran starter Maeda to Minnesota with in-limbo prospect Brusdar Graterol going to the West Coast.

Maeda-for-Graterol is not the only component of the deal. The Dodgers will include $10 million in the trade and get the Twins’ Competitive Balance B (67th overall) pick in 2020, a major league source confirmed.

The clubs also will swap two other prospects. The Twins will send outfielder Luke Raley — whom they received from the Dodgers as part of the Brian Dozier trade in July 2018 — back to his original organization. The player the Twins will receive has not been announced.

The trade was confirmed by a source with direct knowledge of talks between the clubs. The Twins are expected to officially announce the deal on Monday.

But the deal is done. Nearly a week after the Twins initially thought they had a trade with Boston for Graterol secured, the flamethrower is headed to the other coast.

And in one offseason, the Twins forfeited their third-round pick when they signed free agent Josh Donaldson and now have traded their Competitive Balance pick for Maeda. New times, these are.

After a three-team deal involving the Twins, Red Sox and Dodgers fell through Saturday, the organizations dealt directly with one another to section off the megatrade.

According to several reports, Boston and Los Angeles have ironed out the deal that will send All-Stars Mookie Betts and David Price — and money — to the Dodgers. The Dodgers won’t have trouble sending $10 million to the Twins because they are getting $47 million from Boston to help with the $96 million left on Price’s deal.

The Twins were originally going to lose Graterol to Boston, but the Red Sox balked after reviewing his medical records.

The Twins had previously offered the Red Sox a second prospect in the three-way trade, in addition to Graterol. Boston hoped the 21-year-old would be a starting pitcher prospect, but the records suggested relieving might be his best role for the long term. Boston asked for another top-10 prospect to be added to the deal. The Twins balked at that and offered a prospect outside their top 10 instead. That wasn’t enough for the Red Sox.

The saga has been ongoing since Tuesday as the clubs attempted to finalize a deal that has had owners, agents and players’ union executives ranting for closure. Boston, meanwhile, has dealt with fan backlash about potentially dealing the premier right fielder, so maximizing the return is paramount. Betts is due $27 million and will be a free agent after the season; Price has three years and $96 million left on his contract. Boston, eager to avoid luxury tax penalties, will pay a large portion of that salary.

The Dodgers were trying to wrap up a deal with the Angels involving outfielder Joc Pederson, a trade that was dependent on the Dodgers getting Betts. But that deal fell apart Sunday.

The Twins believe adding Maeda deepens their rotation and strengthens their chances of repeating as AL Central champions. Maeda, who turns 32 on April 11, was 10-8 with a 4.04 ERA last season and is 47-35 with a 3.87 ERA in his career with the Dodgers. He joins All-Star righthanders Jose Berrios and Jake Odorizzi at the front of the Twins rotation.

Righthander Homer Bailey, a free-agent acquisition, is expected to be the No. 4 starter. The final spot will go the winner of a spring training pitch-off between lefthanders Devin Smeltzer and Lewis Thorpe and righthander Randy Dobnak. By the second half of the season, righthander Michael Pineda (drug suspension) and veteran lefthander Rich Hill (elbow surgery) will enter the back end of the rotation, giving the Twins what they believe is a deep and talented rotation.

Maeda began his career with the Hiroshima Toyo Carp of the Japanese Leagues in 2008. In 2010 and 2015, he was named the best pitcher in the league. After the 2015 season, he went through the posting system and joined the Dodgers.

He signed an eight year, $25 million deal with the Dodgers but could have made as much as $90.2 million had he reached all of his incentives.

Maeda is guaranteed an annual salary of $3 million, and an additional $150,000 for being on the Opening Day roster.

Maeda’s fastball averaged 92.1 miles per hour last season, but he averaged 9.9 strikeouts per nine innings thanks to a lethal changeup. He will be the second Japanese player and first pitcher to play for the Twins.

Because of the deal, Maeda will receive a $1 million assignment bonus.