The unanimous verdict paving the way for the return of Sharif to participate in the upcoming Parliamentary elections was given by a seven-member bench of the Supreme Court headed by Chief Justice Iftikhar Muhammad Choudhry in a jam-packed court room.
"They have an inalienable right to come back and stay in the country," Chief Justice Iftikhar Chaudhry told the court, referring to Sharif and his brother, Shahbaz Sharif, who is also a politician and was exiled with his brother in 2000.
The court called on the government not to obstruct their return in any way, Chaudhry said.
Both Sharif brothers are in London.
Sharif, who was overthrown by army chief General Pervez Musharraf in a 1999 coup, has vowed to oppose President Musharraf's bid for another term in office.
A senior member of Sharif's Pakistan Muslim League (PML) party said Nawaz Sharif would meet party colleagues in London and then decide when he would return to Pakistan, where he still faces corruption charges.
"It's a landmark decision that will have a far-reaching impact on politics in Pakistan," PML chairman Raja Zafar-ul-Haq told the news agency.
Sharif and Benazir Bhutto, another former prime minister in exile, are both hoping to come home and take part in elections that Musharraf has promised will be free and fair.
"It's a great day for democracy and rule of law and for the fundamental rights of the people of Pakistan. The Supreme Court has delivered justice," said Nadir Chaudhri, spokesman for Nawaz Sharif, speaking in London.
Sharif was sentenced to life in prison on various charges after he was overthrown. He and his family later went to Saudi Arabia after the government said he agreed to 10 years of exile.
However Nawaz Sharif denied any such agreement with the government had been reached and filed a petition in the top court seeking to clear the way for the return of himself and his family.
The timing of a return by Sharif could hardly be more awkward for Musharraf, who is expected to seek re-election from the national and provincial assemblies between mid-September and mid-October and hold parliamentary elections within months.
After the 1999 coup, Musharraf co-opted the rump of Sharif's PML to form his own political base, and analysts say that could now fracture if Sharif were to return.
Shahbaz Sahrif's son, Hamza, said the court ruling was a victory for the country.
"It is not just our victory but a victory for Pakistan," Hamza Sharif told the news agency as jubilant Sharif supporters outside the Supreme Court chanted "go Musharraf, go!". - DDNEWS