(CNN) -- Nelson Mandela, the revered statesman who emerged from prison after 27 years to lead South Africa out of decades of apartheid, has died, South African President Jacob Zuma announced late Thursday. He was 95.
The former president battled health issues in recent months, including a recurring lung infection that led to numerous hospitalizations.
With advancing age and bouts of illness, Mandela retreated to a quiet life at his boyhood home in the nation's Eastern Cape Province, where he said he was most at peace.
Despite rare public appearances, he held a special place in the nation's consciousness.
A hero to blacks and whites
In a nation healing from the scars of apartheid, Mandela became a moral compass.
His defiance of white minority rule and incarceration for fighting against segregation focused the world's attention on apartheid, the legalized racial segregation enforced by the South African government until 1994.
In his lifetime, he was a man of complexities. He went from a militant freedom fighter, to a prisoner, to a unifying figure, to an elder statesman.
Years after his 1999 retirement from the presidency, Mandela was considered the ideal head of state. He became a yardstick for African leaders, who consistently fell short when measured against him.
Warm, lanky and charismatic in his silk, earth-toned dashikis, he was quick to admit to his shortcomings, endearing him further in a culture in which leaders rarely do.
His steely gaze disarmed opponents. So did his flashy smile.
Former South African President F.W. de Klerk, who was awarded the Nobel Peace Prize with Mandela in 1993 for transitioning the nation from a system of racial segregation, described their first meeting.
"I had read, of course, everything I could read about him beforehand. I was well-briefed," he said last year.
"I was impressed, however, by how tall he was. By the ramrod straightness of his stature, and realized that this is a very special man. He had an aura around him. He's truly a very dignified and a very admirable person."
For many South Africans, he was simply Madiba, his traditional clan name. Others affectionately called him Tata, the Xhosa word for father.
A nation on edge
Mandela last appeared in public during the 2010 World Cup hosted by South Africa. His absences from the limelight and frequent hospitalizations left the nation on edge, prompting Zuma to reassure citizens every time he fell sick.
"Mandela is woven into the fabric of the country and the world," said Ayo Johnson, director of Viewpoint Africa, which sells content about the continent to media outlets.
When he was around, South Africans had faith that their leaders would live up to the nation's ideals, according to Johnson.
"He was a father figure, elder statesman and global ambassador," Johnson said. "He was the guarantee, almost like an insurance policy, that South Africa's young democracy and its leaders will pursue the nation's best interests."
There are telling nuggets of Mandela's character in the many autobiographies about him.
An unmovable stubbornness. A quick, easy smile. An even quicker frown when accosted with a discussion he wanted no part of.
Despite chronic political violence in the years preceding the vote that put him in office in 1994, South Africa avoided a full-fledged civil war in its transition from apartheid to multiparty democracy. The peace was due in large part to the leadership and vision of Mandela and de Klerk.
"We were expected by the world to self-destruct in the bloodiest civil war along racial grounds," Mandela said during a 2004 celebration to mark a decade of democracy in South Africa.
"Not only did we avert such racial conflagration, we created amongst ourselves one of the most exemplary and progressive nonracial and nonsexist democratic orders in the contemporary world."
Mandela represented a new breed of African liberation leaders, breaking from others of his era such as Robert Mugabe by serving one term.
In neighboring Zimbabwe, Mugabe has been president since 1987. A lot of African leaders overstayed their welcomes and remained in office for years, sometimes decades, making Mandela an anomaly.
But he was not always popular in world capitals.
Until 2008, the United States had placed him and other members of the African National Congress on its terror list because of their militant fight against the apartheid regime.
Rolihlahla Mandela started his journey in the tiny village of Mvezo, in the hills of the Eastern Cape, where he was born on July 18, 1918. His teacher later named him Nelson as part of a custom to give all schoolchildren Christian names.
His father died when he was 9, and the local tribal chief took him in and educated him.
Mandela attended school in rural Qunu, where he retreated in 2011 before returning to Johannesburg and later Pretoria to be near medical facilities.
He briefly attended University College of Fort Hare but was expelled after taking part in a protest with Oliver Tambo, with whom he later operated the nation's first black law firm.
In subsequent years, he completed a bachelor's degree through correspondence courses and studied law at the University of Witwatersrand in Johannesburg, but left without graduating in 1948.
Four years before he left the university, he helped form the youth league of the African National Congress, hoping to transform the organization into a more radical movement. He was dissatisfied with the ANC and its old-guard politics.
And so began Mandela's civil disobedience and lifelong commitment to breaking the shackles of segregation in South Africa.
In 1956, Mandela and dozens of other political activists were charged with high treason for activities against the government. His trial lasted five years, but he was ultimately acquitted.
Meanwhile, the fight for equality got bloodier.
Four years after his treason charges, police shot 69 unarmed black protesters in Sharpeville township as they demonstrated outside a station. The Sharpeville Massacre was condemned worldwide, and it spurred Mandela to take a more militant tone in the fight against apartheid.
The South African government outlawed the ANC after the massacre, and an angry Mandela went underground to form a new military wing of the organization.
"There are many people who feel that it is useless and futile for us to continue talking peace and nonviolence against a government whose reply is only savage attacks on an unarmed and defenseless people," Mandela said during his time on the run.
During that period, he left South Africa and secretly traveled under a fake name. The press nicknamed him "the Black Pimpernel" because of his police evasion tactics.
The African National Congress heeded calls for stronger action against the apartheid regime, and Mandela helped launch an armed wing to attack government symbols, including post offices and offices.
The armed struggle was a defense mechanism against government violence, he said.
"My people, Africans, are turning to deliberate acts of violence and of force against the government, in order to persuade the government, in the only language which this government shows by its own behavior that it understands," Mandela said during a hearing in 1962.
"If there is no dawning of sanity on the part of the government -- ultimately, the dispute between the government and my people will finish up by being settled in violence and by force. "
The campaign of violence against the state resulted in civilian casualties.
In 1962, Mandela secretly received military training in Morocco and Ethiopia. When he returned home later that year, he was arrested and charged with illegal exit of the country and incitement to strike.
Mandela represented himself at the trial and was briefly imprisoned before being returned to court. In 1964, after the famous Rivonia trial, he was sentenced to life in prison for sabotage and conspiracy to overthrow the government.
At the trial, instead of testifying, he opted to give a speech that was more than four hours long, and ended with a defiant statement.
"I have fought against white domination, and I have fought against black domination," 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."
His next stop was the Robben Island prison, where he spent 18 of his 27 years in detention. He described his early days there as harsh.
"There was a lot of physical abuse, and many of my colleagues went through that humiliation," he said.
One of those colleagues was Khehla Shubane, 57, who was imprisoned in Robben Island during Mandela's last years there. Though they were in different sections of the prison, he said, Mandela was a towering figure.
"He demanded better rights for us all in prison. The right to get more letters, get newspapers, listen to the radio, better food, right to study," Shubane said. "It may not sound like much to the outside world, but when you are in prison, that's all you have."
And Mandela's khaki prison pants, he said, were always crisp and ironed.
"Most of us chaps were lazy, we would hang our clothes out to dry and wear them with creases. We were in a prison, we didn't care. But Mandela, every time I saw him, he looked sharp."
After 18 years, he was transferred to other prisons, where he experienced better conditions until he was freed in 1990.
Months before his release, he obtained a bachelor's in law in absentia from the University of South Africa.
Calls for release
His freedom followed years of an international outcry led by Winnie Mandela, a social worker whom he married in 1958, three months after divorcing his first wife.
Mandela was banned from reading newspapers, but his wife provided a link to the outside world.
She told him of the growing calls for his release and updated him on the fight against apartheid.
World pressure mounted to free Mandela with the imposition of political, economic and sporting sanctions, and the white minority government became more isolated.
In 1988 at age 70, Mandela was hospitalized with tuberculosis, a disease whose effects plagued him until the day he died. He recovered and was sent to a minimum security prison farm, where he was given his own quarters and could receive additional visitors.
Among them, in an unprecedented meeting, was South Africa's president, P.W. Botha.
Change was in the air.
When Botha's successor, de Klerk, took over, he pledged to negotiate an end to apartheid.
Free at last
On February 11, 1990, Mandela walked out of prison to thunderous applause, his clenched right fist raised above his head.
Still as upright and proud, he would say, as the day he walked into prison nearly three decades earlier.
"As I walked out the door toward the gate that would lead to my freedom, I knew if I didn't leave my bitterness and hatred behind, I'd still be in prison," he said at the time.
He reassured ANC supporters that his release was not part of a government deal and informed whites that he intended to work toward reconciliation.
Four years after his release, in South Africa's first multiracial elections, he became the nation's first black president.
"The day he was inducted as president, we stood on the terraces of the Union Building," de Klerk remembered years later. "He took my hand and lifted it up. He put his arm around me, and we showed a unity that resounded through South Africa and the world."
Broken marriage, then love
His union to Winnie Mandela, however, did not have such a happy ending. They officially divorced in 1996 after several years of separation.
For the two, it was a fiery love story, derailed by his ambition to end apartheid. During his time in prison, Mandela wrote his wife long letters, expressing his guilt at putting political activism before family. Before the separation, Winnie Mandela was implicated in violence, including a conviction for being an accessory to assault in the death of a teenage township activist.
Mandela found love again two years after the divorce.
On his 80th birthday, he married Graca Machel, the widow of former Mozambique president, Samora Machel.
Only three of Mandela's children are still alive. He has 17 grandchildren and 12 great-grandchildren
South Africa's fight for reconciliation was epitomized at the 1995 rugby World Cup Final in Johannesburg, when it played heavily favored New Zealand.
As the dominant sport of white Afrikaners, rugby was reviled by blacks in South Africa. They often cheered for rivals playing their national team.
Mandela's deft use of the national team to heal South Africa was captured in director Clint Eastwood's 2009 feature film "Invictus," starring Morgan Freeman as Mandela and Matt Damon as Francois Pienaar, the white South African captain of the rugby team.
Before the real-life game, Mandela walked onto the pitch, wearing a green-and-gold South African jersey bearing Pienaar's number on the back.
"I will never forget the goosebumps that stood on my arms when he walked out onto the pitch before the game started," said Rory Steyn, his bodyguard for most of his presidency.
"That crowd, which was almost exclusively white ... started to chant his name. That one act of putting on a No. 6 jersey did more than any other statement in bringing white South Africans and Afrikaners on side with new South Africa."
During his presidency, Mandela established the Truth and Reconciliation Commission to investigate human rights abuses during apartheid. He also introduced housing, education and economic development initiatives designed to improve the living standards of the black majority.
A promise honored
In 1999, Mandela did not seek a second term as president, keeping his promise to serve only one term. Thabo Mbeki succeeded him in June of the same year.
After leaving the presidency, he retired from active politics, but remained in the public eye, championing causes such as human rights, world peace and the fight against AIDS.
It was a decision born of tragedy: His only surviving son, Makgatho Mandela, died of AIDS at age 55 in 2005. Another son, Madiba Thembekile, was killed in a car crash in 1969.
Mandela's 90th birthday party in London's Hyde Park was dedicated to HIV awareness and prevention, and was titled 46664, his prison number on Robben Island.
A resounding voice
Mandela continued to be a voice for developing nations.
He criticized U.S. President George W. Bush for launching the 2003 war against Iraq, and accused the United States of "wanting to plunge the world into a Holocaust."
And as he was acclaimed as the force behind ending apartheid, he made it clear he was only one of many who helped transform South Africa into a democracy.
In 2004, a few weeks before he turned 86, he announced his retirement from public life to spend more time with his loved ones.
"Don't call me, I'll call you," he said as he stepped away from his hectic schedule.
'Like a boy of 15'
But there was a big treat in store for the avid sportsman.
When South Africa was awarded the 2010 football World Cup, Mandela said he felt "like a boy of 15."
In July that year, he beamed and waved at fans during the final of the tournament in Johannesburg's Soccer City. It was his last public appearance.
"I would like to be remembered not as anyone unique or special, but as part of a great team in this country that has struggled for many years, for decades and even centuries," he said. "The greatest glory of living lies not in never falling, but in rising every time you fall."
CNN's Robyn Curnow, Michael Martinez, Matt Smith and Alanne Orjoux contributed to this report.