The former Juventus and Inter Milan striker will join initially on a year-long loan before signing a permanent deal at the end of the season.
He is due to undergo a medical on Monday, after which he will sign a four-year contract.
“I’m delighted that everything has been resolved for the best, even if the situation was not easy,” said Ibrahimovic.
“Now I will return to Milan but for a different team to Inter; things are going forwards.
“Milan are one of the best teams in the world because of their team and their tradition. With (Alexandre) Pato and Ronaldinho we have a fantastic strike-force, now it’s down to us.
“I think Milan’s fans will have fun in the stadium with us three.”
Ibrahimovic, who was a fan favourite at Inter, brushed off talk about any ill-will their fans might harbour towards him.
“I don’t think they will think about me, given they won everything,” he said, referring to Inter’s treble triumph last season.
“This situation, which was created at Barcelona, has given me a lot of adrenaline and now my dream is to win everything with Milan.”
Ibrahimovic was Barca’s marquee signing a year ago but was considered a disappointment in his first season in Spain and essentially became surplus to requirements in Catalunya following the €40 million acquisition of Spain forward David Villa from Valencia.
The deal is a real coup for cash-strapped Milan, who earlier this month entered into a complicated loan deal with Genoa to land Ghana midfielder Kevin-Prince Boateng.
Milan vice-president Adriano Galliani, who had been in Barcelona since Wednesday to try to find an agreement, explained how the deal works.
“We’ve come to an agreement with Barcelona for the loan with the right to buy for €24 million, which will be paid in three €8 million payments over the next three seasons (after this one),” he said.
“Ibrahimovic will sign a four-year deal which will be ratified after his medical on Monday.
“We will unveil him after he has come back from international duty.”
Milan also signed Boateng on loan because they do not currently have the funds to buy players.
Boateng was bought by Genoa from Portsmouth for €6.5 million and immediately loaned to Milan, who will sign him in a year, at a profit for Genoa.
Ibrahimovic becomes one of a small number of players to have played for Italy’s big three teams.
He spent two seasons at Juventus, having joined from Ajax, before going on to grace the black and blue shirt of Inter for three years, winning the title in every season.
He was sold to Barcelona a year ago for €46 million plus Cameroonian striker Samuel Eto’o, in a transfer that put the Swede’s value at around €69 million.