Nelson Mandela, whose victory against apartheid united his native South Africa and changed the course of modern history, has died following a long illness.

The Nobel Peace laureate, who spent nearly three decades as a political prisoner before going on to lead his country, passed away at his Johannesburg home surrounded by his family.

South African President Jacob Zuma said "the nation has lost its greatest son", adding: "He is now resting. He is now at peace."

Mr Mandela, who was 95, will get a state funeral and national flags will be lowered to half-mast.

He had been receiving medical treatment for the last three years for a prolonged lung infection and for the last six months had been critically ill.

"Our people have lost a father," said Mr Zuma.

"Although we knew this day was going to come, nothing can diminish our sense of a profound and enduring loss.

"His tireless struggle for freedom earned him the respect of the world. His humility, passion and humanity, earned him their love."

The anti-apartheid icon served as South Africa's first black president from 1994 to 1999 after spending 27 years in jail, including the notorious Robben Island prison.

Video:South Africans Dance For Mandela

Madiba - as he was affectionately known by many South Africans - was released in 1990 and went on to guide his country to democracy, bringing an end to white minority rule and securing black people the right to vote.

UK Prime Minister David Cameron, speaking outside Downing Street, said: "Tonight one of the brightest lights of our world has gone out.

"Nelson Mandela was not just a hero of our time, but a hero of all time.

"He achieved more than can be expected of any man - and today he's gone home," said President Obama.

"We've lost one of the most influential, courageous and profoundly good human beings that any of us will share time with on this earth."

"He no longer belongs to us - he belongs to the ages."

The Queen said she was "deeply saddened" by Nelson Mandela's death, saying he "worked tirelessly for the good of his country, and his legacy is the peaceful South Africa we see today".

Video:Nelson Mandela 'Is Now At Peace'

Zindzi and Zenani Mandela, Mr Mandela's daughters, were informed of his death as the premiere of a film about their father's life got under way in London.

They are understood to have been told just as the film started - but insisted that the screening continue.

Speaking on the red carpet, Zindzi Mandela had earlier told reporters her father was "fine" and that "we are hoping to see more of him".

Video:How Mandela Will Be Remembered

Others inside the Leicester Square premiere were left stunned as the film's producer announced Mr Mandela's death as the closing credits rolled. A moment of silence was held.

Prince William, who was also at the premiere of Mandela: Long Walk To Freedom, paid tribute from the lobby of the cinema.

"It was extremely sad and tragic news," he said.

Video:Mandela's Impact On South Africa

"We were just reminded of what an extraordinary and inspiring man Nelson Mandela was and my thoughts and prayers are with him and his family right now."

Crowds gathered outside Mr Mandela's Johannesburg home after his death, singing songs in celebration of his achievements.

Sky News' Alex Crawford, who is at the scene, said people were dancing and clapping.

Video:The Campaign To Free Nelson Mandela

"People are upset," she said. "They've come with flowers, people are obviously very emotional about it, but they are also in a very celebratory mood as well.

"It was very sombre when we arrived, (but) more and more people have gathered here and the mood is entirely different.

"It has changed to singing tribute songs, they've sung the national anthem, they're singing a lot of songs from way back when they were pushing for democratic rights."

One woman among the crowds told Sky News: "We're really really sad but we show this by singing ... the struggle songs all in his memory. He left a huge legacy, everybody still looks up to him all over the world."

"I hope the whole world is behind us - even after his passing."

Another mourner outside his house said she was 12 years old when Mr Mandela was released.

"For me, he represented hope, he represented freedom." she said.

"So today I'm here to show I'm thankful for him. I grew up in a rural area, so it was just blacks. All I knew of white people was going to town. There were places where you could go and couldn't go. I remember from my childhood not being able to go where I wanted to go.

"As he said, the walk is far from being over, but it's a far cry from what it used to be before, so for that I'm thankful. My kids don't know what we knew, but then that's because of him."

Video:PM: Mandela 'A Hero Of All Time'

Mr Mandela is survived by his third wife, Graca Machel, and daughters Makaziwe, Zindzi and Zenani.

The former president's body has been taken to a military hospital in Pretoria. It is thought his body will lie in state for three days before a funeral is held on Saturday in Qunu, the village in Eastern Cape where he was born.