Iranian workers weld two gas pipes together at the start of construction on a pipeline to transfer natural gas from Iran to Pakistan, in Chabahar, southeastern Iran, near the Pakistani border, on March 11. (Vahid Salemi/AP)

Raising their fists triumphantly on a remote patch of border, Pakistani President Asif Ali Zardari and Iranian President Mahmoud Ahmadinejad broke ground this week on a natural gas pipeline, hyping it as a conduit to prosperity for their cash-strapped countries. But the deal also is widely seen here as Zardari’s latest grasp for legacy in the final days of his five years as a deeply unpopular leader.

The United States has long discouraged the pipeline with threats of economic sanctions against Pakistan. U.S. officials, as well as most Pakistani analysts, say the multibillion-dollar project — meant to ease Pakistan’s severe energy shortages by tapping its neighbor’s gas fields — is largely a pipe dream, pursued for 18 years and still fraught with uncertainties over financing.

But for Zardari the deal with Iran is also a chance to restore some luster to the ruling Pakistan People’s Party, which he heads, before its term expires at midnight Saturday and new elections are called.

Zardari’s critics consider him a corrupt, grasping and inept plutocrat who ruined the economy. He gets a bottom-of-the-barrel ranking among the nation’s leaders, with a 14 percent approval rating in the most recent Pew Research Center poll.

Even so, in a country that has been ruled by the military for nearly half its existence, he will likely secure a place in history as the first Pakistani president to preside over a democratic transfer of power between civilian governments, if elections are held as expected in May.

“He’s survived, but at the cost of what?” asked Najam Sethi, one of Pakistan’s most venerated journalists and commentators. “There’s been a terrible mismanagement of the economy and law and order. And there hasn’t been any improvement in the lives of poor people. It’s worse.”

Zardari, elected in 2008 after the assassination of his wife, former prime minister Benazir Bhutto, can stay for a second term if he wins over an electoral college of parliamentarians and provincial assemblies. He is still considered a viable politician by dint of incumbency and the powerful machine he runs. Moreover, the government makes frequent appeals to the memory of his late wife and provides millions of Pakistanis with cash handouts under a program in her name.

Politically, Zardari has used the pipeline pact to symbolically snub the United States, which sees Pakistan’s dealings with Iran as potential violations of the sanctions imposed on Tehran for its nuclear program. Staring down Uncle Sam translates into support here because of rampant anti-American sentiment. And the promise of natural gas, however distant, might play well with some Pakistanis, who suffer through energy outages every day.

The Iranians have laid about 600 miles of pipe on their side of the border; Tehran has promised Pakistan $500 million to start construction on its side.

But Islamabad has to come up with at least $1 billion more to finish the project, at a time when growth is falling, state receipts are low, the national currency has been hammered against the dollar and businesses are crippled by power shortages.

Evidently only words, not cash, have been exchanged between Iran and Pakistan, so Washington still describes the energy deal as tentative. The State Department continues to issue dutiful warnings, while simultaneously expressing doubts that the pipeline will ever come to pass.

“We’ve heard this pipeline announced about 10 or 15 times before in the past,” State Department spokeswoman Victoria Nuland said Monday, the same day Ahmadinejad and Zardari unveiled a plaque, draped in velvet, to mark the start of construction.

“The United States is not hurrying because they feel neither country — Pakistan or Iran — has the money to complete the project,” said Javed Mahmood, a Karachi-based editor of banking and corporate publications.

The Karachi stock exchange nose-dived after the pipeline ceremony, but it regained ground Tuesday after investors realized that sanctions were not immediately forthcoming.

“The business community is in panic about possible sanctions being imposed on us,” said Saad Bin Naseer, chief operating officer of Sherman Securities, a brokerage house in Karachi. Even so, he dismissed the pipeline plan as “all political promises to the people of Pakistan, nothing else.”

Some analysts predict the deal will fall apart anyway, voided by the next administration if Zardari’s party does not secure a majority of seats in Parliament. The most likely premier, in that case, would be former prime minister Nawaz Sharif, head of the opposition Pakistan Muslim League-N.

The race has been complicated by the entry of cricket hero Imran Khan, who has built a political following among young people, in particular with his campaign against corruption. Khan is not likely to claim enough seats to become prime minister, but his Movement for Justice party will gain a meaningful voice in the National Assembly and Senate.

Former military ruler Pervez Musharraf, meanwhile, has vowed to return to Pakistan within weeks from a five-year exile to put his old general’s hat into the ring, but few analysts see him as having much impact on the race.

As the Pakistan People’s Party wraps up its unprecedented five-year stint this week, accolades are being heard throughout the capital — but most, if not all, come from the party itself.

Prime Minister Raja Pervez Ashraf congratulated his government Wednesday for strengthening democracy — which even its harshest critics concede it has managed to do despite economic crisis and an intractable Taliban insurgency.

“We have been working on multiple fronts to achieve energy security for the country,” Ashraf told his cabinet Wednesday, according to an official release.

He put the nebulous Iran deal at the top of the list.

“This project will not only boost the economies of both the countries,” he said, “but also bring prosperity to the entire region.”