Tim Kurkjian says the Yankees' acquisition of Gerrit Cole makes them not only the best team in the American League but also the best team in baseball. (0:44)

Prized free-agent pitcher Gerrit Cole and the New York Yankees have agreed to a record nine-year, $324 million contract, sources told ESPN's Jeff Passan.

The deal includes an opt-out after five years, according to Passan, and it also has a full no-trade clause, sources told ESPN. It surpasses the deal Stephen Strasburg finalized with the Washington Nationals on Monday for most total money and annual average salary for a pitcher, at $36 million.

Cole, 29, the runner-up to teammate Justin Verlander for the AL Cy Young Award, was dominant in 2019, posting a 20-5 record in the regular season as the Houston Astros led the majors with 107 wins.

The hard-throwing right-hander set an Astros record by winning his last 16 regular-season decisions and topped the AL with a career-best 2.50 ERA. His career-high 326 strikeouts were the most in the majors and broke an Astros franchise record that had stood since 1979, when J.R. Richard fanned 313.

Cole had only one loss after May 22. That came in Game 1 of the World Series against the Nationals, but he redeemed himself with a stellar outing in Game 5. In the postseason, Cole went 4-1 with a 1.72 ERA in 36⅔ innings.

Cole grew up a Yankees fan and attended several games at the old Yankee Stadium. He said before Game 3 of the ALCS that his favorite players were Derek Jeter and Mariano Rivera.

Yankees general manager Brian Cashman visited Cole and his wife, Amy, in California last week, bringing along manager Aaron Boone, new pitching coach Matt Blake and special adviser Andy Pettitte.

Team owner Hal Steinbrenner was directly involved in some of the talks, speaking with Cole's agent, Scott Boras, by phone, and it was his decision to push the offer from an eighth year to a ninth year, sources told ESPN's Buster Olney. The Los Angeles Dodgers were heavily involved, and were perceived by some executives to be the second-place finisher. The Los Angeles Angels' offer may have fallen short of the $300 million threshold.

Passan reported last week that signing Cole was the Yankees' top offseason priority and that Cashman had ownership-level approval to offer a record-setting deal.

"I think we all understand we have a special team that's hopefully in the middle of a chance to do some great things," Boone said from the winter meetings. "Any time you're talking about a player the caliber of Gerrit Cole, and knowing what he can potentially mean to our club, it's no surprise that we are as invested as we are in pursuing him."

New York has not won the World Series since 2009 and sought an ace to head a rotation that includes Luis Severino, Masahiro Tanaka, James Paxton, J.A. Happ and Domingo German, who might be suspended at the season's start under baseball's domestic violence policy.

Cashman executed the move out of the same playbook he used after the 2008 season, when he gave CC Sabathia a $161 million, seven-year deal to lead a staff and establish a clubhouse presence.

Cole will join a Yankees team with a young core of hitters that includes Aaron Judge, Gleyber Torres and Gary Sanchez, entering a window in which New York thinks it can compete consistently for championships.

Cole Strikes It Rich Gerrit Cole and the Yankees have agreed to a nine-year, $324 million contract, sources told ESPN's Jeff Passan. Here's a look at where it ranks in MLB history, based on total value: Player Value Type Mike Trout $426.5M Extension Bryce Harper $330M Free Agent Giancarlo Stanton $325M Extension Gerrit Cole $324M Free Agent Manny Machado $300M Free Agent -- ESPN Stats & Information

Cole was drafted by the Yankees out of high school with the 28th pick in the first round in 2008, but he chose to go to UCLA. Then he was drafted first overall by the Pittsburgh Pirates three years later. He finished fourth in NL Cy Young Award voting in 2015 and earned the first of his three All-Star selections that season, but he was less effective in his other four seasons in Pittsburgh.

After five seasons with the Pirates, Cole was traded to the Astros in January 2018 in exchange for pitchers Joe Musgrove and Michael Feliz, third baseman Colin Moran and outfielder Jason Martin. In his two seasons with Houston, armed with a revitalized four-seam fastball and improved mechanics in which he left fewer pitches out of the strike zone, Cole went 35-10 with a 2.68 ERA and 602 strikeouts -- good for 12.1 WAR.

FanGraphs' pitch values had Cole's fastball as the most valuable in the majors last season, and his slider was in the top 10.

Despite Cole's natural talent, Houston Astros manager AJ Hinch said during the postseason that the pitcher's "biggest strength is his mind."

Cole finished fifth in AL Cy Young voting in 2018. In his seven MLB seasons, he has a 94-52 record with a 3.22 ERA and 1,336 strikeouts in 1,195 innings. His ratio of 10.062 strikeouts per nine innings ranks sixth among active players and eighth all time.

ESPN's Marly Rivera and The Associated Press contributed to this report.