The Dutch midfielder, who is in his second season at Brazilian club Botafogo, was the leading candidate to replace Massimiliano Allegri, who was sacked on Monday.
"Considering my relationship with the president [Silvio Berlusconi], when he called me yesterday I couldn't say no after 10 years spent there [at Milan]," the 37-year-old midfielder said.
"This experience in the last year and a half has made me grow a lot and will help me in my next step, which will be as Milan coach."
The Dutchman is the only player to have won the Champions League four times with three different clubs: Ajax, Real Madrid and AC Milan.
"I am retiring from football after 22 years," he said. "It has been a difficult night but I am satisfied by what I've achieved in my career."