Ibrahimovic's last game for AC Milan was back in March as he worked his way back to full fitness following a serious knee injury suffered last summer.
Ibrahimovic's last match as a professional was as a late substitute for Sweden in a 3-0 defeat against Belgium on March 24.
The much travelled striker played just four times for AC Milan this season.
In a storied career, Ibrahimovic represented nine clubs, including two spells at AC Milan which brought two Serie A titles.
He also played for Barcelona, Inter Milan, Paris Saint Germain, Juventus, Ajax Amsterdam, Malmo and Manchester United.
Speaking to the home fans after AC Milan wrapped up their Serie A campaign with a 3-1 win over Hellas Verona on Sunday, Ibrahimovic said: "I have so many memories and lived so many emotions in here, the first time I arrived here you gave me happiness. The second time love.
"I want to thank my family, everyone close to me, for their patience. I want to thank my second family, the players. I want to thank (AC Milan head coach Stefano) Pioli and his staff for the responsibility you have given me. I want to thank the managers for the opportunity.
"But most important of all: from my heart I want to thank you fans. You welcomed me with open arms, you made me feel at home. I will be a Milan fan for life. The time has come to say goodbye to football, but not to you.
"I have too many emotions that are passing through me. See you around, if you're lucky. Forza Milan and goodbye".
Ibrahimovic retires as Sweden's all-time top scorer with 62 goals in 121 appearances.