The Houston Astros and Justin Verlander are reuniting in hopes of securing a third championship together.

The Astros reached agreement with the New York Mets on Tuesday to reacquire Verlander, bringing the reigning American League Cy Young Award winner back to Houston, the team announced Tuesday. Outfielder Drew Gilbert, rated as the Astros’ best prospect by MLB.com, is heading to New York in the deal, as is minor league outfielder Ryan Clifford.

Clifford, an 11th-round draft pick last year, is ranked fourth in Houston’s system after an impressive stint in High-A.

Verlander, 40, returned from Tommy John surgery to capture his third Cy Young in Houston in 2022, then helped lead the team to its second World Series title in six years. The Astros chose not to aggressively pursue a reunion with Verlander over the offseason, instead putting their faith in what looked like a young and deep rotation, while Verlander signed a two-year, $86.7 million deal with the free-spending Mets.

His contract also included a $35 million option for 2025 that vests if he accumulates at least 140 innings in 2024, a circumstance that scared teams away. The Mets will pay $35 million out of the $58 million remaining on Verlander’s deal in 2023 and 2024 and $17.5 million of his 2025 option if it vests, sources told ESPN’s Jeff Passan.

“[General manager Dana Brown] and his team worked on it hard,” Astros owner Jim Crane told The Associated Press on Tuesday. “After we looked at the numbers — it’s always tough to give up prospects, but I think they determined that it was the right move. We needed starting pitching. He’s been throwing well. And I think the other factor is they ate a lot of the contract. So it wasn’t a really hard decision. It was just would we give up enough prospects?”

The Mets have woefully underperformed this year, triggering a surprising sell-off, and the Astros were in the market for starting pitching by midseason, prompting a star-studded reunion. Several teams were in on Verlander, most notably a Los Angeles Dodgers team with more intriguing prospects to offer. But Verlander held a full no-trade clause and the Astros held the upper hand thanks to his strong relationship with Crane.

“Justin and I always got along,” Crane said. “We’ve had direct contact with each other on a number of things. Certainly not this one, but I know him well, and every time he was here, we did what we said we were going to do. So I think he had some trust in coming back here, certainly. And he’s had great successes. So I think that certainly helped.”

The Baltimore Orioles, Atlanta Braves and San Diego Padres were also reportedly looking into Verlander.

Verlander becomes the fourth high-profile Mets player to depart in recent days, joining co-ace Max Scherzer (Texas Rangers), closer David Robertson (Miami Marlins) and outfielder Mark Canha (Milwaukee Brewers). The Astros, only a half-game behind the Rangers in the AL West, were looking to upgrade their rotation with Lance McCullers Jr. and Luis Garcia lost for the season.

“It improves my heart’s function, you know what I mean?” Astros manager Dusty Baker said of having Verlander back in the rotation. “And for a guy who’s had a stroke, heart function is very, very important. And that does my heart well.”

Verlander got off to a slow start this season but has regained his form of late, posting a 1.49 ERA over his past seven starts.

The Astros initially acquired Verlander from the Detroit Tigers in a late-August trade in 2017, two months before the franchise won a championship that was later tainted by the sign-stealing scandal. Verlander went on to spend the better part of the next half-decade with the Astros, serving as one of the cornerstone players for a franchise that established itself among the most dominant in the sport.

The Associated Press contributed to this story.