The tabloid printed an apology at the top left of page 5 of Saturday's paper under the headline "Ross Barkely: Sun apology".
Sun columnist MacKenzie suggested that Everton player Barkley, whose grandfather was born in Nigeria, was punched in a nightclub because he was similar to a zoo animal.
It reads: "On April 14 we published a piece in the Kelvin MacKenzie column about footballer Ross Barkley which made unfavourable comparisons between Mr Barkley and a gorilla.
"At the time of publication the paper was unaware of Ross Barkley's heritage and there was never any slur intended. As soon as his background was drawn to our attention, the article was removed from online.
"We have been contacted by lawyers on behalf of Ross Barkley, who has made a formal complaint about the piece.
"The Sun has apologised for the offence caused by the piece. We would like to take this opportunity to apologise personally to Ross Barkley."
In the article published on 14 April, MacKenzie, a former Sun editor wrote that the 23-year-old footballer's eyes had given him a "similar feeling when seeing a gorilla at the zoo."
His eyes made him "certain not only are the lights not on, there is definitely nobody at home", he added.
Next to the article was a picture of a gorilla, beside a photograph of Barkley.
In the outcry that followed, the Sun newspaper suspended MacKenzie. Everton banned Sun journalists from its stadium and Liverpool's mayor, Joe Anderson, reported MacKenzie to the police for making "racial slurs". Merseyside police said an investigation was being carried out to "establish the full circumstances of the incident".
In response to the accusations, MacKenzie told the Press Association: "I had no idea of Ross Barkley's family background and nor did anybody else. For the mayor of Liverpool and a handful of others to describe the article as racist is beyond parody."