Free-agent ace Jacob deGrom and the Texas Rangers agreed to a $185 million, five-year contract Friday.

The two-time Cy Young Award winner leaves the New York Mets after nine seasons — the past two shortened substantially by injuries.

After making his first start in early August last season, deGrom went 5-4 with a 3.08 ERA in 11 outings. He helped the Mets reach the playoffs, then passed up a $30.5 million salary for 2023 and opted out of his contract to become a free agent for the first time.

Texas announced the signing Friday night after the 34-year-old deGrom passed his physical. A person with direct knowledge of the deal disclosed the financial terms to The Associated Press. The person spoke on condition of anonymity because the club did not announce those details.

“We are thrilled that Jacob deGrom has decided to become a Texas Ranger,” executive vice president and general manager Chris Young said in a statement. “Over a number of seasons, Jacob has been a standout major league pitcher, and he gives us a dominant performer at the top of our rotation. One of our primary goals this offseason is to strengthen our starting pitching, and we are adding one of the best."

Texas went 68-94 last season and then hired Bruce Bochy, a three-time World Series champion with San Francisco, as its new manager. The Rangers’ six straight losing seasons are their worst skid since the franchise moved from Washington in 1972.

The Rangers were also big spenders in free agency last offseason, signing shortstop Corey Seager ($325 million, 10 years) and second baseman Marcus Semien ($175 million, seven years).

This latest blockbuster move comes just before baseball's winter meetings, which begin early next week in San Diego. The Rangers said deGrom will be introduced in a news conference at Globe Life Field next week following the winter meetings.

When healthy, deGrom is perhaps baseball's most dominant pitcher. His 2.52 career ERA ranks third in the expansion era (since 1961) behind Los Angeles Dodgers lefty Clayton Kershaw (2.48) and Hall of Famer Sandy Koufax (2.19) among those with at least 200 starts.

The right-hander is 4-1 with a 2.90 ERA in five career postseason starts, including a win over San Diego in the wild-card round this year that extended the Mets' season. New York was eliminated the next night.

A four-time All-Star and the 2014 NL Rookie of the Year, deGrom was a ninth-round draft pick by the Mets in 2010 out of Stetson University, where he played shortstop before moving to the mound. He was slowed by Tommy John surgery early in his professional career and didn't reach the majors until age 26.

Once he arrived, though, he blossomed. He helped the Mets reach the 2015 World Series and earn a 2016 playoff berth before winning consecutive NL Cy Young Awards in 2018 and 2019.

But injuries to his elbow, forearm and shoulder blade have limited him to 26 starts over the past two seasons. He compiled a career-low 1.08 ERA over 92 innings in 2021, but did not pitch after July 7 that year because of arm trouble.

DeGrom is 82-57 with 1,607 strikeouts in 1,326 innings over nine big league seasons.

New York won 101 regular-season games last season, second-most in franchise history, but was caught by NL East champion Atlanta down the stretch and settled for a wild card.

After declining his 2023 option, ending his contract with the Mets at $107 million over four years, deGrom rejected a $19.65 million qualifying offer in November, so New York will receive draft-pick compensation for losing him.

The fan favorite becomes the latest in a long line of ace pitchers to leave the Mets for one reason or another, including Nolan Ryan, Tom Seaver, Dwight Gooden and David Cone.

With several holes on their starting staff, the Mets have shown interest in free agents Justin Verlander and Carlos Rodón to pair with 38-year-old Max Scherzer atop the rotation. Now, with deGrom gone, signing one of those two could become a much bigger priority.