Zidane told a news conference that "everything changes" and "that's why I took this decision".
He leaves having guided the Spanish club to three successive Champions League titles and one La Liga success since taking over in January 2016.
"I love this club," he added.
"What I think is that this team needs to continue winning but I think it needs a change, a different voice, another methodology. And that's why I took this decision."
Zidane, 45, took over after Rafael Benitez was sacked and was in charge for 149 games. He steered Real to 104 wins and 29 draws, had 69.8% win rate, and won nine trophies.
He said in February that he would walk away if he felt "there is nothing more to give".
However, the timing of his announcement still came as a shock just days after Real beat Liverpool 3-1 in the Champions League final.
That win saw him join Bob Paisley (three at Liverpool) and Carlo Ancelotti (AC Milan two, Real Madrid one) as the only managers to have won the Champions League/European Cup three times.
"It's a strange moment to do so, I know, but an important one too," he added on Thursday. "I had to do this for everyone."
BBC
More about: RealMadrid