Nelson Mandela has left hospital and has gone to his Johannesburg home, where he is continuing to receive intensive care, the South African presidency says on its website.
The announcement came a day after officials denied reports that the 95-year-old had already been discharged.
The statement says Mr Mandela condition remains critical and at times unstable.
South Africa’s first democratically elected president has been in hospital since June with a lung infection.
Mandela’s key dates
1918 – Born in the Eastern Cape
1944 – Joined African National Congress
1956 – Charged with high treason, but charges dropped
1962 – Arrested, convicted of sabotage, sentenced to five years in prison
1964 – Charged again, sentenced to life
1990 – Freed from prison
1993 – Wins Nobel Peace Prize
1994 – Elected president
1999 – Steps down as leader
2001 – Diagnosed with prostate cancer
2010 – Appears at football World Cup
BBC History: Mandela’s defiant freedom speech
The Nobel Peace Prize laureate is revered around the world for leading the fight against white minority rule and preaching reconciliation with the white community despite being imprisoned for 27 years.