The Yankees traded for an ace Thursday to empower their starting rotation for 2017 and beyond.

Hours before the MLB trade deadline, the Bronx Bombers acquired Sonny Gray, 27, from the Oakland Athletics.

In exchange, Oakland gets three minor league prospects: Dustin Fowler, James Kaprielian, and Jorge Mateo.

Gray is 6-5 this year with a 3.43 ERA and a 1.175 WHIP in 16 starts this season. He will not be a free agent until after the 2019 season.

Separately in New York, the Mets agreed to trade reliever Addison Reed to the Boston Red Sox.

The 31-year-old has a 166 ERA+ this season, with 19 saves, and an 8-1 strikeout-to-walk ratio.

The Amazins' are getting back three minor league pitchers in that trade.