The announcement ends days of speculation over the future of the 26-year-old attacking midfielder, a Moroccan international.
"Ajax and Chelsea have reached an agreement for the transfer of Hakim Ziyech. The player will join the Premier League club on July 1st 2020 and will finish the season in Amsterdam," the Eredivisie champions said in a statement.
"The clubs have agreed a deal of €40 million euros. This sum could potentially increase to a maximum of €44 million, with variable factors."
Chelsea confirmed the deal, praising Dutch-born Ziyech as a "prolific scorer throughout his career."
"Ziyech is a left-footed attacker who is comfortable playing off the right flank and coming inside, as he has often done in recent years to such devastating effect for Ajax, or on the left to attack with width and deliver into the box," Chelsea said.
The London-based side added: "The move is subject to the player agreeing personal terms and he will remain at the Dutch club for the rest of this season."
Ziyech joined Ajax in 2016 from fellow Eredivisie club FC Twente for a fee of 11 million euros, and has now scored 49 goals in 160 appearances for Ajax.
His contract at Ajax was due to run until June 2022.
Ziyech was a key figure in Ajax's sensational run to the Champions League semi-finals last year.
But he reportedly wanted more football in Europe's top flight after the Dutch side were eliminated in the group stage this year -- in part because they lost at home to Chelsea and later threw away a three-goal lead at Stamford Bridge.
Ziyech made his comeback Wednesday evening with his team's victory in Arnhem (0-3) in the quarter-finals of the Dutch KNVB Cup after a calf muscle tear in January.
Dutch media this week said Frank Lampard believed Ziyech "is a top player and such an essential reinforcement to his 11 that he gave the club instructions to have a deal done before the summer."
Clubs can agree and sign transfers outside the English Premier League's January transfer window, but players may not be registered with new clubs until it opens again in the summer.
Ajax is known for selling home-grown talent to richer European clubs. After last season, they sold Matthijs de Ligt to Juventus and Frenkie de Jong to Barcelona.
In 2018, Ziyech, who was born in the central Dutch town of Dronten, was crowned Dutch Player of the Year.
"He brings technique, originality, bravery, depth and enjoyment," to the game, said De Volkskrant daily newspaper.
"After eight seasons in the Eredivisie he'll leave behind an emptiness" on Dutch football fields, the paper lamented.
The top two finishers in the Dutch league qualify each year for the Champions League and Ajax are top, 10 points clear of third-place Willem II.
Chelsea are fourth in the Premier League, which would earn a Champions League spot, but their poor recent form has allowed a chasing pack of five clubs to close in.
They however remain in this season's Champions League.