Nelson Mandela, South Africa's first black president and the man widely seen as the architect of a peaceful transition to democracy after three centuries of apartheid rule, has died at his home in the Johannesburg suburb of Houghton.
He had been receiving home-based intensive care after being discharged from hospital in September.
The South African president Jacob Zuma confirmed the news in a statement broadcast live on national television.
He said Mandela had "departed" and was now at peace.
He said South Africa had lost its greatest son and its people had lost a father.
America's first black president paid tribute to Nelson Mandela in a sombre statement delivered from the White House, in which Barack Obama described the personal inspiration he had drawn from the man he called Madiba.
"I am one of the countless millions who drew inspiration from Nelson Mandela's life," said a visibly moved Obama.
"And like so many around the globe, I cannot fully imagine my own life without the example that Nelson Mandela set, and so long as I live I will do what I can to learn from him."
The US president, who met Mandela once as a senator and was prevented from visiting him during a trip to South Africa in June by the latter's illness, has been reluctant to overemphasise the comparisons, but revealed how much his own political career had been influenced by the anti-apartheid struggle.
"My very first political action, the first thing I ever did that involved an issue or a policy or politics, was a protest against apartheid," said Obama. "I studied his words and his writings. The day that he was released from prison gave me a sense of what human beings can do when they're guided by their hopes and not by their fears."
Obama did not say when his first protest took place, but he is known to have become involved in anti-apartheid politics at Occidental College in Los Angeles, between 1979 and 1981.
In London, David Cameron said Mandela was a towering figure: "A great light has gone out in the world. Nelson Mandela was a towering figure in our time; a legend in life and now in death – a true global hero. Across the country he loved they will be mourning a man who was the embodiment of grace. Meeting him was one of the great honours of my life."
Labour leader Ed Miliband said that the world had lost the inspirational figure of our age. "Nelson Mandela taught people across the globe the true meaning of courage, strength, hope and reconciliation. From campaigner to prisoner to president to global hero, Nelson Mandela will always be remembered for his dignity, integrity and his values of equality and justice.
"He was an activist who became president and a president who always remained an activist. Right to the end of his life he reminded the richest nations of the world of their responsibilities to the poorest. Above all, he showed us the power of people, in the cause of justice, to overcome the mightiest obstacles."
France's president, François Hollande, said: "Nelson Mandela made history, that of South Africa and that of the whole world. A tireless fighter against apartheid, he defeated it with his courage, his obstinacy and his perseverance.
"Throughout all these years, Nelson Mandela has incarnated the South African nation, the cement of its unity and the pride of Africa. He mobilised all his strength to put his country in its rightful place among the main world powers ... right to the end of his life he served peace. Nelson Mandela's message will not disappear.
"He will continue to inspire those who fight for freedom and give confidence to people who defend just causes and universal rights. He showed that human will could not only break chains of subjugation, but free the energy to succeed in building a common destiny. France shares the infinite sadness of the South African people."
Manmohan Singh, the Indian prime minister, referenced his country's own independence leader Gandhi. "A giant among men has passed away. This is as much India's loss as South Africa's. He was a true Gandhian. His life and work will remain a source of eternal inspiration for generations to come. I join all those who are praying for his soul." Gandhi spent formative years as a political activist in South Africa and Mandela knew Gandhi's son Manilal, historians pointed out.
Japan's prime minister, Shinzo Abe, described Mandela as a "great leader" who "fought with a strong will to eliminate apartheid and achieved a great deal by putting national reconciliation at the centre of his nation-building". The foreign minister, Fumio Kishida, said: "I wish to express my heartfelt respect for the achievements of the former South African president and hope that the government and people of South Africa will overcome their grief and go on to further develop their country."
The Israeli prime minister, Binyamin Netanyahu, said Mandela "was never haughty. He worked to heal rifts within South African society and succeeded in preventing outbreaks of racial hatred." Shimon Peres, president of Israel, praised Mandela as "a builder of bridges of peace and dialogue who paid a heavy personal price for his struggle in the years he spent in prison and fighting for his people".