In recent days, US officials, including Hillary Clinton, the secretary of state, had spoken to the country's leaders, urging them to reach a deal.
Washington and other Western nations have been concerned that the crisis would weaken the country's battle against Taliban and al-Qaeda fighters operating along its border with Afghanistan.
Al Jazeera's Imran Khan, reporting from Lahore, said that Monday's announcement could be seen as an embarrassing climb-down by the government or a move towards national political unity.
But for the several hundred jubilant lawyers and activists gathered outside Chaudhry's Islamabad residence to celebrate, it was clear how they were taking it: the government backing down in the face of their protests.
Tariq Mehmud, a retired judge and a leader of the lawyers' campaign, said it was a "victory for those who fought for independence of judiciary".
But he cautioned that Chaudhry "has to forget the past. He has to forget the conduct of those who were apparently against him as well as us".
March called off
The government concession came as thousands of protesters led by Nawaz Sharif, the main opposition leader, held a day of protest in Lahore on Sunday, and set off for Islamabad for the climax of a series of protests they had dubbed "the long march".
To stop them from driving into the capital, the authorities had beefed up security, put the army on alert and positioned containers and trucks across roads outside the city, with violent confrontation appearing inevitable.
Following Gilani's announcement, Sharif said he was calling off his protest march.
"We are now calling off this long march," he said from inside his vehicle amid a sea of jubilant supporters in the central city of Gujranwala on Monday.
"Today the nation has received very happy news. We have said that we will restore the judges and the independent judiciary and by the grace of Allah we have achieved it," he said, adding that "very soon we will play our role in implementing real democracy in this country".
Sharif, leader of the Pakistan Muslim League-Nawaz (PML-N) party, had thrown his support behind the protest campaign by lawyers and judges, and senior members of his party were quick to claim an emphatic win for the government's climb-down.
Sharif latched on to Chaudhry's cause two years ago but the current crisis began when Asif Ali Zardari, the president, ejected the PML-N from power in Punjab last month, after the supreme court barred Sharif and his younger brother Shahbaz from holding elected office.
Chaudhry, the former supreme court justice, was dismissed by Pervez Musharraf, the former president, on November 3, 2007 along with 60 other judges, when Musharraf declared emergency rule in a move to extend his presidency for another term.
Most of the judges had since been reinstated after Zardari took over as president six months ago.
But Zardari repeatedly reneged on promises to return Chaudhry to his post with analysts suggesting that he feared the chief justice could pose a threat to his position.
Gilani's early morning announcement on Monday concluded a day of dramatic developments.
|Anti-government protesters fought running battles with police in Lahore [AFP]
Before dawn on Sunday, hundreds of police surrounded Sharif's residence in Lahore, carrying an order for his house arrest.
Sharif rejected the order as illegal and later left the house in a convoy of vehicles as police stood by.
Some of the protesters defied police barricades to gather near the city's main courts complex and pelted riot police with rocks.
One mob smashed the windows of buses parked along the route of Sharif's convoy, while another broke into the main post office building, trashing furniture and then clambering on to the roof to hurl rocks at police below.
Police responded with tear gas and batons, and detained a handful of protesters.
Later, the crowd swelled to several thousands and police again pulled back. Many were black-suited lawyers, but most appeared to be supporters of Sharif.
The government had put the army on alert and temporarily detained hundreds of activists nationwide to prevent them from travelling to Lahore or Islamabad.
But its resolve appeared to waver on Sunday amid signs of internal party dissent.
A day earlier, Sherry Rehman, the information minister, resigned, apparently over government attempts to censor critical media coverage.