Security remains a key component. During their speeches, Pakistan’s Prime Minister Nawaz Sharif and Xi both emphasized China’s support for Pakistan’s ongoing counterterrorism efforts. For the Chinese, Small said, counterterrorism is central to the relationship and to bringing stability to their western periphery. “It’s about stability in Pakistan itself, Afghanistan in the wider picture and safe havens in Pakistan’s tribal areas that have served as training bases and sources of ideological inspiration for militants from China’s Xinjiang province,” he said. The far-western province Xinjiang is home to China’s Muslim Uighur minority, many of whom complain of cultural and economic repression by the government in Beijing and the country’s ethnic Han majority.

“This will put China much more center stage politically in Pakistan than ever before,” said Andrew Small, the author of the book “The China-Pakistan Axis: Asia’s New Geopolitics.” Traditionally, he said, “The economic dimension of the relationship has been thin.” With the exception of a few road projects, the numbers — including bilateral trade figures — have been quite small when compared with the rest of the region. “Now they are adding a serious economic dynamic to a relationship that has always been a security-based relationship,” added Small, who is a transatlantic fellow at the German Marshall Fund think tank in Washington, D.C.

For Pakistan, the Chinese plans promise a much-needed boost to the country’s creaky infrastructure. They include, for example, a slew of power projects for a country where some areas suffer up to 18 hours without electricity each day. Other plans involve a network of roads and railway lines for an economy that is estimated to lose up to 6 percent of its gross domestic product because of poor transport links. The Arabian Sea port of Gawadar will be developed, and a highway linking the Arabian Sea to the western provinces of China is to be the central artery of what planners call a Pakistan-China economic corridor.

The deals were signed in Islamabad on Monday amid extravagant displays of pomp and ceremony. As Chinese President Xi Jinping flew over the capital for his first visit to Pakistan, a flock of Pakistani jets guided his plane to its descent. On the tarmac, Pakistan’s entire civilian and military leadership were arrayed to greet him. The road leading into Islamabad was festooned with Pakistani and Chinese flags, and signs with Xi’s image dangled from lampposts.

For much of the half-century since China and Pakistan forged close ties, the relationship has been one based on mutual military and security needs. They both, for example, had India as an adversary. But now China is rolling out its largest infrastructure development project in Pakistan through a flurry of investment deals worth $46 billion, building on Beijing’s vision of a new Silk Road connecting the world’s largest economy to different parts of Europe, the Middle East and other parts of Asia.

For several years, the Chinese have been discreetly lending their voice to a chorus of Western alarm about the presence of insurgent fighters along the Pakistan-Afghanistan border, particularly in North Waziristan, where the Pakistani army is finally conducting a military offensive.

Taming radicalism will be crucial to seeing the infrastructure development take place. For example, many of the projects are contingent on security in Pakistan’s restive southwestern province of Baluchistan. A Baluch separatist insurgency has flickered there for the past decade, involving the sabotage of gas supplies — which the Baluch believe are rightfully theirs — to the rest of the country. The Chinese have studied the risks for some time and see the planned projects as a long-term means of addressing the problem. “The Chinese are willing to press ahead despite these risks,” Small said. Although the plans could be derailed by security problems, he added, they could help stabilize the country economically and politically.

One of the projects in Baluchistan is an Iran-Pakistan gas pipeline, which had been shelved under the threat of U.S. sanctions but is now being revived — with the Chinese willing to finance it — as Tehran looks poised to finally emerge from pariahdom. At the same time, Pakistan is negotiating a deal for the import of 3,000 megawatts of electricity from Iranian gas power plants based, a Pakistani government minister told Al Jazeera.

As China assumes a larger political role in Pakistan, it wants to act as a moderating influence. It wants Islamabad to improve relations not just with Iran through energy links and with Kabul through talks on a postwar political settlement in Afghanistan but also with the one regional capital with which they have both gone to war: New Delhi.

“The Chinese still see the Pakistanis as playing a counterbalancing role,” Small said, referring to how Pakistan has played a subsidiary role in the India-China rivalry. “But they want Pakistan to be stable and at peace with major powers.”

The United States wants this as well. But the big contrast with the U.S.-Pakistan relationship lies in domestic popular support. A Pew Research Center survey conducted last year showed that 78 percent of Pakistanis view China favorably, the highest figure for any country polled. A mere 14 percent said they view the U.S. favorably. Analysts put the vast difference down to the fact that the Chinese sit primly aloof from domestic politics and aren’t militarily involved in Pakistan. The infrastructure projects are likely to cement China’s popularity because they involve investment rather than aid and the results will be concrete, visible developments rather than scattered through myriad donor projects.

The Chinese do not want to displace the U.S. as a player in Pakistan. Beijing will still want Islamabad to turn to Washington for economic assistance and arms procurement. Pakistan has just put in an order this month for 15 new AH-1Z Viper helicopters from the U.S. worth $1 billion to replace its ailing fleet. Even when Islamabad’s relationship with Washington nosedived to its lowest point after the 2011 U.S. raid that killed Osama bin Laden in Pakistan, Beijing encouraged Islamabad to rebuild its relationship with the U.S.

The investment program will be rolled out slowly, in stages. For the Chinese, it is a means of countering slowing growth at home by recycling its trade surpluses through Pakistan, with companies in China’s interior hopefully benefiting from the new infrastructure projects. The Chinese have turned to their own banks to finance the plan and have insisted that Pakistan provide some of the financing as a way of having a stake in the project.

It will be up to the Pakistanis to get the projects up and running within the next couple of years and to stabilize the security situation to ensure that happens. The Chinese have a lot riding on these deals, and the Pakistanis have raised their expectations. “There’s an urgency in measuring up to those expectations,” says Mosharraf Zaidi, a policy analyst and former adviser to Pakistan’s Foreign Ministry. “This is the one relationship that if Pakistan fails to deliver, it will render itself friendless.”