NEW YORK (AP) — The most stunning deal done at this year's trade deadline didn't come together until the final 20 minutes, and the result is a starting rotation that's sure to be long remembered.

The Houston Astros acquired ace Zack Greinke on Wednesday, adding another All-Star and Cy Young Award winner to a formidable rotation that already included Justin Verlander and Gerrit Cole.

The AL West leaders got Greinke in a startling trade with Arizona for four minor leaguers, a deal in which the Diamondbacks agreed to pay the Astros $26 million to cover much of the roughly $76 million the pitcher is due.

"We have two pitchers on our team, maybe more that are Hall of Fame-caliber," Astros general manager Jeff Luhnow said. "And I think we have a rotation that's set up to compete in any series against any team for the rest of this year."

Arizona general manager Mike Hazen said the trade was rushed into place in the final 20 minutes before the 4 p.m. deadline to complete deals to have players eligible for the postseason. Astros players learned about the trade at 4:07 p.m. in the visiting clubhouse in Cleveland, and Cole said there was "a lot of hooting and hollering" over "getting a Hall of Fame pitcher, a craftsman."

"We are just really shocked and ecstatic," Cole said.

Greinke pitched five innings earlier in the day at Yankee Stadium, giving up two runs to New York. He was pulled from the game during a rain delay, and manager Torey Lovullo interrupted Greinke watching video of the start so Hazen could inform him of the deal.

The 35-year-old Greinke left the ballpark without commenting to reporters. The trade was officially announced after 5:30 p.m., following Arizona's 7-5 loss.

The Astros won the 2017 World Series and lost the 2018 ALCS to eventual champion Boston. They loaded up again with Greinke, getting a six-time All-Star and the 2009 AL Cy Young Award winner. He is 10-4 with a 2.90 ERA this season.

Greinke's addition gives the Astros four starting pitchers with ERAs in the top 15 in the majors this year. Verlander is fifth with a 2.73 ERA, Greinke is ninth, Cole is 11th at 2.94 and Wade Miley ranks 14th at 3.06. Verlander leads the AL in wins (14) and ERA, and Cole tops with the majors with 212 strikeouts.

Verlander is second among active players in career victories at 218 and Greinke is third at 197. Those two top the list among active pitchers for career wins above replacement, per, with Greinke at 70 and Verlander at 68.

"If we stay healthy," Luhnow said, "this team is as good as any team I've ever seen."

There was a palpable buzz in Houston's clubhouse. Cole credited owner Jim Crane, Luhnow and the front office staff for their hard work in making the trade happen.

"What a pickup," Cole said. "They nailed it. They did a magnificent job."

Over 16 stellar seasons, Greinke has gotten something of a crabby reputation — for instance, he said last month he'd rather never throw a no-hitter because "a bunch of nonsense comes with it." He was well received over four seasons in Arizona, even becoming a regular in the Diamondbacks war room during the amateur draft. The Diamondbacks raved about his clubhouse presence.

"Zack got a bad rap from places he was before, but everyone here loved him," Arizona reliever Archie Bradley said.

Arizona agreed to send Houston $24 million to offset much of the $74,161,290 Greinke is owed in salary plus $2 million to cover the assignment bonus he gets for being traded. The Diamondbacks pay the Astros $2 million on Nov. 1 for the assignment bonus and pay Houston $3,333,333 on Oct. 15 plus $10,333,333 each on July 1 in 2020 and 2021.

Greinke's $206.5 million, six-year contract includes a $31.5 million salary for this year — which has $10,161,290 remaining — plus $32 million in each of the next two seasons. His deal defers $10.5 million in 2019 salary and $11 million in each of the next two years, and Houston assumes responsibility for the deferred money being accrued starting Thursday.

The Astros, who began the day with an eight-game division lead over Oakland, also acquired two other pitchers, getting starter Aaron Sanchez and reliever Joe Biagini from Toronto, along with catcher Martin Maldonado from the Cubs.

"Houston made some big deals. They're really good. They were good before," Red Sox President of Baseball Operations Dave Dombrowski said.

For Greinke, the Diamondbacks got right-handers J.B. Bukauskas and Corbin Martin, outfielder Seth Beer and infielder Joshua Rojas.

For Biagini, Sanchez and minor league outfielder Cal Stevenson, the Blue Jays acquired outfielder Derek Fisher. The Astros also sent catcher Max Stassi to the Angels for minor league outfielders Rainier Rivas and Raider Uceta. Maldonado came in exchange for outfielder Tony Kemp.

Sanchez was 3-14 with a 6.07 ERA. A 2016 All-Star, the 27-year-old righty has been sidelined by fingernail problems in the past.

"One opportunity that I get to do is to go down to Houston and learn from guys like Justin Verlander, like Gerrit Cole, who's had an unbelievable year. Like Zack Greinke," Sanchez said.

Biagini, 29-year-old righty, was 3-1 with one save and a 3.86 ERA in 49 games.

In 2017, Houston acquired Verlander from Detroit on Aug. 31, which was the last day for deals that season to make players eligible for the playoffs.

In a 16-year career with Kansas City, Milwaukee, the Angels, Dodgers and Diamondbacks, Greinke has gone 197-122.

The Diamondbacks added two pitchers for their rotation, getting Zac Gallen from Miami and Mike Leake from Seattle. The 23-year-old Gallen is 1-3 with a 2.72 ERA over his first seven major league starts this season. Leake recently took a perfect game into the ninth inning, and was 9-8 with a 4.34 ERA.

More From 1460 ESPN