Zack Wheeler has reached an agreement on a three-year extension that begins in 2025 and runs through the 2027 season with the Philadelphia Phillies, the team announced Monday, bypassing the possibility that the ace pitcher will become a free agent in the fall.

The deal is worth $126 million, according to sources.

With a salary of $42 million, Wheeler’s deal is the most lucrative extension in baseball history in terms of average annual value. It also is in the neighborhood of the richest salaries for pitchers. Max Scherzer and Justin Verlander signed multiyear deals as free agents with the New York Mets that averaged $43.3 million.