By Syed Shoaib Hasan
BBC News, Islamabad
The ruling sparked a frenzy of celebration among party supporters
"It is a triumph for all of us, especially the 160 million people of Pakistan," said a visibly emotional Hamza Sharif outside the Supreme Court.
Hamza Sharif is the nephew of deposed former Prime Minister Nawaz Sharif and son of his fellow exile and brother Shahbaz Sharif.
He was speaking after Pakistan's top court ruled that his uncle and father were free to return to the country.
Waving to hundreds of chanting supporters, even Mr Sharif appeared to be overwhelmed by the sudden resurrection of the Sharif brand.
His father and uncle went into exile from Pakistan after President Pervez Musharraf came to power in a 1999 military coup.
In the second week of August, the Sharifs filed a petition asking the Supreme Court to allow them to return home.
Thursday's hearing was led by Chief Justice Iftikhar Chaudhry, who recently overcame a hugely controversial and botched attempt by Gen Musharraf to sack him.
The speed with which the judiciary moved on the Sharif petition has left the government taken aback.
On Wednesday, legal documents were submitted and there was talk of an adjournment.
But Thursday's proceedings began with a sense of inevitability.
Supporters of Mr Sharif's Pakistan Muslim League party crowded the outside and inside of the court.
Many of the PML(N) faithful had to stand for the duration of the seven-hour hearing but none of them seemed to mind.
The defence team, led by ex-Supreme Court judge Fakhruddin G Ebrahim, stressed one point over and over.
Referring to an alleged agreement by the Sharifs not to return to Pakistan for 10 years, he stated that any contract contravening the inalienable rights of a citizen under the constitution must be void.
The government's legal team, however, was more inclined to go in circles.
Lawyer Ahmed Raza Kasuri insisted, despite several admonitions from the judges, that this alleged 'understanding' with the Sharifs not to come back for a decade superseded the constitution.
He went on to say the Sharifs were bound to honour the supposed deal and called on the court to dismiss their petition.
He was asked how that was possible when any agreement which breached basic constitutional rights was surely void.
The lawyer's reply stunned the court.
"Yes, an agreement cannot supersede the constitutional rights, but an understanding can," he told the judges' bench.
Advocate Ibrahim Safeer dropped an even bigger bombshell.
He told the court that the petition was not maintainable as the country was in a state of emergency.
He claimed the emergency declared after Gen Musharraf's coup had never been called off.
As such, he declared, fundamental rights remained suspended.
As the judges began to take him to task, a senior PML(N) leader sniggered: "With idiots like these, we don't even need a defence."
By now the writing seemed to be on the wall.
When Advocate General Malik Qayuum stepped up to the podium, he accepted that any agreement which contravened basic rights could not stand in court.
Former Pakistan Prime Minister Nawaz Sharif can return whenever he likes
An hour later the judges declared that Nawaz Sharif and his brother Shahbaz could return to the country anytime they wished.
The decision sparked jubilation and triumph among the PML(N) cadres, while the government lawyers quietly left the court.
Outside anti-Musharraf slogans reached a crescendo.
PML(N) workers distributed sweets, hugged each other and danced themselves into a euphoric frenzy.
The crowds swelled as Hamza Sharif made his way out of the court.
Everybody wanted a glimpse of the only Sharif family member present.
The crowds jostled and pushed him and his retinue as they made their way to the road outside.
There, standing among the party faithful, a beaming Hamza talked to the media while shaking a hundred eager hands.
"We have always fought for the masses, and this is their victory as well as ours," he said.
"Pervez Musharraf's time is now at an end."