His release follows the relaxation of apartheid laws – including lifting the ban on leading black rights party the African National Congress (ANC) – by South African President FW de Klerk.
Mr Mandela appeared at the gates of Victor-Verster Prison in Paarl at 1614 local time – an hour late – with his wife Winnie.
Holding her hand and dressed in a light brown suit and tie he smiled at the ecstatic crowds and punched the air in a victory salute before taking a silver BMW sedan to Cape Town, 40 miles away.
People danced in the streets across the country and thousands clamored to see him at a rally in Cape Town.
Doctors treated over a hundred people as police clashed with youths looting shops in various cities and townships and several people were reported shot dead.
Mr Mandela, the deputy-president of the ANC, appeared on the balcony of Cape Town’s City Hall to speak to the 50,000 people assembled outside at 2000 local time. He acknowledged Mr de Klerk was a man of integrity, but said: “Our struggle has reached a decisive moment. Our march to freedom is irreversible.”
“Now is the time to intensify the struggle on all fronts. To relax now would be a mistake which future generations would not forgive,” he continued.
As he addressed the crowd South African state television broadcast a profile of Mr Mandela – including a BBC interview from 1961 – which was the first time he had been shown speaking on TV.
Now 71, the lawyer from the Transkei homeland was convicted of treason and sabotage in June 1964 and sentenced to life imprisonment. He spent most of his sentence on Robben Island, off Cape Town, doing hard labor.
Since the 1980s he has refused numerous offers for early release from the government in Pretoria because of the conditions attached.
Courtesy BBC News
Nelson Mandela succeeded Oliver Tambo as president of the ANC later in 1991.
He divorced Winnie the next year following her convictions for kidnapping and being accessory to an assault.
Mr Mandela and FW de Klerk shared the Nobel Peace Prize in 1993 for their efforts to transform South African society.
In the first multi-racial elections in the country’s history he was elected president and the ANC gained 252 of the 400 seats in the national assembly.
He was succeeded as ANC president by Thabo Mbeki in 1997 and stepped down in favour of Mr Mbeki as national president after the 1999 elections.
Mr Mandela re-married in 1998 and was diagnosed with prostate cancer in 2001, aged 83.