Nelson Mandela was the glowing beacon of hope, shining across South Africa and the world, whose 27 years in jail left him without a trace of bitterness or hatred against those who practised the evil of apartheid.
From his prison cell the man who was to become president of his beloved South Africa did more than any person alive to end this scourge and to bring about black majority rule in his country.
It was Mr Mandela, even through his long and lonely incarceration, whose sheer, unwavering resolve to end the iniquities in South Africa assuaged the despair of millions of blacks who existed under the tyranny of apartheid.
Never did he compromise his inflexible principles, which provided a source of great strength to fellow prisoners. More than once he rejected offers of freedom with strings attached. Only a free man can negotiate, he said. A prisoner cannot enter into contracts.
Mr Mandela was finally released by President FW de Klerk on Sunday February 11 1990, sometime after the then president had lifted the ban on the African National Congress.
It was soon after his release that Mr Mandela and his delegation formally agreed to the end of the armed struggle.
Four years later, on May 10 1994, Mr Mandela was inaugurated as the first democratically-elected president of South Africa, a post he held until June 1999, when he formally retired from public life.
Even then, he spent much of his time travelling the world, meeting foreign statesmen and being hailed, wherever he went, as a remarkable man who never demonstrated even a trace of rancour and vindictiveness towards those who maintained the tyrannical regime and who threw him into prison.
His appeals for peace and harmony, not simply in the formerly race-ridden state of South Africa, but throughout the world, including, and especially, the Middle East, were often more effective than those issued even from the White House.
He was revered worldwide as a man of peace and forgiveness, a man who did not know the meaning of the word "malice".
Nelson Rolihlahla Mandela was born on July 18 1918 in a village near Umtata in the Transkei. He was given the name Nelson by a teacher at his school.
His father, a counsellor to the Thembu royal family, died when Nelson was nine, and he was placed in the care of the acting regent of the Thembu people.
He joined the African National Congress in 1943, first as an activist, then as the founder and president of the ANC Youth League.
Mandela married his first wife, Evelyn Mase, in 1944. They divorced in 1957, after having three children. He qualified as a lawyer and, in 1952, opened a law practice in Johannesburg with his partner, Oliver Tambo.
Together, Mr Mandela and Mr Tambo campaigned against apartheid. In 1956, Mandela was charged with high treason, with 155 other activists. But the charges against him were dropped after a four-year trial.
The resistance to apartheid grew, mainly against the new pass laws, which dictated where blacks were allowed to live and work.
In 1958, he married Winnie Madikizela, who later played an active role, both politically and in the campaign - which eventually became worldwide - to free her husband from prison.
Two years later, the ANC was outlawed and Mr Mandela went underground. Tension with the apologists for apartheid soared to new heights when, in 1960, 69 black people were shot dead by police in the Sharpeville massacre.
This signalled the end of peaceful resistance. Mr Mandela, who was already by then national vice-president of the ANC, launched a campaign of sabotage against the South African economy.
With the banning of the ANC, he was detained until 1961 when he went underground to lead a campaign for a new national convention. Umkhonto we Sizwe (MK), the military wing of the ANC, was born the same year. Under his leadership, it launched that campaign against the Government and economic installations.
In 1962, Mr Mandela left the country for military training in Algeria and to arrange training for other MK leaders. On his return, he was arrested for leaving the country illegally and for incitement to strike.
He conducted his own defence and used the stand at this and a subsequent trial for treason to convey his beliefs about equality, democracy and freedom.
He said: "I have cherished the ideal of a democratic and free society in which all persons live together in harmony and with equal opportunities. It is an ideal which I hope to live for and to achieve. But if needs be, it is an ideal for which I am prepared to die."
Mr Mandela, however, was convicted and jailed for five years. While serving that sentence he was charged in the winter of 1964 with sabotage and sentenced to life imprisonment.
In the 12 months between 1968 and 1969, Mr Mandela's mother died and his eldest son was killed in a car crash, but he was not allowed to attend their funerals.
He remained in prison on the notorious Robben Island for 18 years before being transferred to Polismoor Prison on the mainland in 1982.
In prison, Mr Mandela never compromised his political principles. During the 1970s, he refused the offer of remission of sentence if he recognised Transkei and settled there. In the following decade, he again rejected president PW Botha's offer of freedom if he renounced violence.
But, as he and other ANC leaders languished in prison or lived in exile, South African black township children helped to sustain the resistance. Hundreds were killed and thousands injured before the schoolchildren's uprising was crushed.
Meanwhile, in 1980, his great friend Mr Tambo, who was in exile, launched an international campaign for his release.
As he did so, the world community tightened the sanctions first imposed on South Africa in 1967 against the apartheid regime.
This pressure produced results. President de Klerk lifted the ban on the ANC and Mr Mandela was released, amid jubilation, from prison.
Within days, the ANC and the National Party began talks about forming a new multi-racial democracy for South Africa.
However, violent clashes broke out between supporters of the Inkatha Freedom Party, a Zulu group led by Chief Buthelezi and ANC supporters.
Despite attempts to resolve the problems through talks, the violence escalated and the Inkatha targeted ANC strongholds with support from the white police force.
Relations grew tense as the violence persisted, but the two leaders - President de Klerk and Mr Mandela - met sporadically in an attempt to stop the bloodshed.
In 1992, Mr Mandela divorced his wife Winnie, after she was convicted on charges of kidnapping and accessory to assault.
In December the following year, Mr Mandela and Mr de Klerk were awarded the Nobel Peace Prize. Mr Mandela said it was an accolade to all people who had worked for peace and stood against racism.
Five months later, for the first time in South Africa's history, all races voted in democratic elections. Mr Mandela was elected President, in scenes of joy, with the ANC winning 252 of the 400 seats in the national assembly.
His greatest problem was the housing shortage for the poor and the slum townships blighting the major cities.
He entrusted his deputy, Thabo Mbeki, with the day-to-day business of the Government, while he concentrated on the ceremonial duties of a leader, building a new, international image of South Africa. In that context, he persuaded the country's multinational corporations to remain and invest in South Africa.
Mr Mandela gave up the presidency of the ANC in December 1997 in favour of Mr Mbeki. He stepped down as president of the country after the ANC's landslide victory in the summer of 1999, again for Mr Mbeki.
Subsequently, he married Graca Machel, the widow of the former president of Mozambique. In January 2005, he suffered a personal tragedy when his eldest son, lawyer Makgatho Mandela, 54, died of Aids-related complications. His father said the only way to fight the disease's stigma was to speak openly about it.
Even in "retirement", Mr Mandela did not remain silent. He accused the United Kingdom and the United States of encouraging international chaos by ignoring other countries and assuming the role of "policemen of the world".
He also openly criticised Washington and London for taking military action in Iraq and Kosovo without seeking permission from the United Nations Security Council.
But as the years progressed, his ailing health saw him retreat from public life.
In 2008, he made a rare visit to the UK to attend a concert marking his 90th birthday.
The following year, the United Nations declared July 18 Mandela Day, in recognition of his birthday.
But a family bereavement and increased fragility meant that he maintained a low profile at football's World Cup 2010 in South Africa, only briefly appearing at the finale.
It was an event that the former president had lobbied for on behalf of his country.
Mr Mandela's role in South Africa hosting - and going on to win - 1995's Rugby World Cup had by this time been turned into a film, Invictus. American actor Morgan Freeman received an Oscar nomination for portraying Mr Mandela in his bid to use sport to unite the country post-apartheid.
South Africa's football players were unable to match the earlier success of their rugby counterparts but the successful hosting of the event and the cross-racial support for the national team again underlined Mr Mandela's achievements.
In January 2011, Mr Mandela spent two nights in a Johannesburg hospital for what his doctor said was a respiratory infection.
Officials said his office received more than 10,000 letters of good wishes, including from US President Barack Obama.
In June 2011 Mr Mandela issued a message calling Albertina Sisulu "one of the greatest South Africans" as the country mourned a woman celebrated for her role in the fight against apartheid.
She had collapsed and died at her Johannesburg home at the age of 92.
Mr Mandela's message, read by his wife Graca Machel during the funeral at a Soweto football stadium, set off a brief rally of singing and dancing in his honour.
In November 2011 the Prince of Wales and the Duchess of Cornwall inquired about Mr Mandela's state of health, while they were visiting South Africa.
They were told that the 93-year-old was "fine, happy and peaceful and enjoying life" at his birthplace in rural Qunu in the Eastern Cape.
In February 2012 it was announced that the complete series of South African bank notes would bear Mr Mandela's image.
President Jacob Zuma said at the central bank offices: "With this humble gesture, we are expressing our deep gratitude as the South African people, to a life spent in service of the people of this country and in the cause of humanity worldwide."
The announcement was made on the 22nd anniversary of the anti-apartheid leader's release from prison.
Later that month an increasingly fragile Mr Mandela hit the headlines again, this time when he spent a night in hospital for a long-standing abdominal complaint.
The former president's health took another turn for the worse in December last year when he was admitted to a military hospital for treatment for a lung infection and surgery to remove gallstones.
Worshippers gathered at the Regina Mundi Catholic church - a centre of anti-apartheid protests and funerals - in the Soweto area of Johannesburg to pray for the former leader.
He spent Christmas Day in hospital with his wife and family members at his bedside during his three-week stay.
He was again admitted to hospital in Pretoria in March this year, and on April 6 he was discharged from a hospital after treatment for pneumonia, which included a procedure in which doctors drained fluid from his lung area.
On June 8 he was admitted to hospital again with a recurrence of his lung infection, and in recent weeks his health deteriorated.
Mr Zuma said on June 23 that Mr Mandela's health had deteriorated and he was in a "critical condition", but added that he was "in good hands" as well-wishers continued to voice support for a father figure and symbol of integrity who will be remembered as the man who saved South Africa.