In 1965, a Pakistani military delegation traipsed to Beijing in hope of replacing equipment they'd lost in the previous year's war with India.

Premier Zhou Enlai, meeting the delegation, was bewildered by their request for only 14 days' ammunition. 'How can a war be fought in that short time?' Zhou then asked: 'I would be interested to know if you have prepared the people of Pakistan to operate in the rear of the enemy...I am talking about a People's Militia being based in every village and town'. The Sandhurst-educated generals were taken aback. 'What does Zhou Enlai know about soldiering anyway?'

This story appears early in Andrew Small's outstanding new book The China-Pakistan Axis: Asia's New Geopolitics. It is a reminder that the two countries are odd bedfellows, lacking the cultural affinity that might be implied by General Xiong Guangkai's quip that 'Pakistan is China's Israel'.

China has repeatedly left Pakistan to stew in its own juices in moments of peril, from 1965 to more recent crises.

During Pakistan's dismemberment in 1971, its desperate commanders sent delusional messages to troops, promising US and Chinese intervention: 'yellow from the north and white from the south'. But the cavalry never came. The economic statistics are also resoundingly underwhelming. Vietnam, with an economy half the size of Pakistan's, has four times the bilateral trade. China pledged US$66 billion of assistance to Pakistan between 2001 and 2011, but only 6% ever materialised.

This is certainly at odds with the ritualistic Pakistani hyperbole that marks every bilateral visit. As Pakistani Prime Minister Nawaz Sharif put it on his last trip, 'our friendship is higher than the Himalayas and deeper than the deepest sea in the world and sweeter than honey'. But Pakistan's real value to China, explains Small, is 'an India that is forced to look nervously over its shoulder at its western neighbour is easier for Beijing to manage'.

And so, China accelerated Pakistan's nuclear weapons program over three decades, starting with fissile material in the 1980s, advanced missiles in the 1990s and the steady construction of new reactors (in flagrant violation of China's own non-proliferation commitments) in the 2000s and beyond. The two countries established a 'coordination bureau' in 1969 to arm, fund and train Indian insurgents, a policy from which China, argues Small, 'has never backed away entirely'. Beijing has also shielded Pakistani intelligence officers from UN terrorism sanctions.

This history is largely well known, and Small pulls it all together deftly and with meticulous sourcing. But he supplements it with extensive interviews, and these paint a richer picture of Chinese foreign policy in motion. A few themes stand out.

The first is a generational shift in China's South Asia hands, at the same time as disquiet began to rise about Pakistan's stability. Small explains that 'the older generations are almost exclusively India experts, and still stress the need for "balance" in China's relationships with the two South Asian powers'. But the younger analysts include a 'growing number of Pakistan hands who generally believe that China should accept its rivalry with India and embrace the strategic relationship with Pakistan'. If this is correct, it helps clarify Chinese behaviour towards India over the past few years, such as an oddly timed flare-up on the border just as President Xi Jinping was beginning his high profile visit to Delhi last year

China has been able to manage this relationship with Pakistan relatively well in part because of its highly flexible, narrowly focused approach towards international terrorism: 'don't bother us' – ie. keep away from Uighurs – 'and we won't bother you', a proposition sweetened with 'money or small arms supplies' to placate what might be otherwise threatening groups. These sweeteners include transfers of heavy weaponry and explosives to the Taliban, whom Beijing hosted this month, and even a reported meeting with al Qaeda 'to sound out its intentions'. The close ties between Pakistan's intelligence services and manifold jihadists, a source of serious US-Pakistan tension, has been exploited by China as an opportunity, with Pakistani spies brokering meetings and leaning on key groups to respect China's red lines.

At the same time, Small's interviewees make clear this isn't a blank cheque. 'If India launches air strikes on Pakistan, we would be willing to respond', says one Chinese expert, reflecting on the Mumbai attacks, 'but when it's Pakistan that causes the problem we can't back them'. Another, discussing Chinese contingency planning in the event of a crisis involving nuclear weapons, clarifies that 'China is willing to help Pakistan defend a Pakistani bomb. We won't help them protect an Islamic bomb'. 

Above all, Chinese officials have been disturbed by escalating violence both in Xinjiang and against the more than 10,000 Chinese nationals within Pakistan. China is particularly neuralgic about the East Turkestan Islamic Movement (ETIM), which operates in Pakistan's tribal areas. Small records a litany of complaints that could easily have come from jaded American officials: 'when we provide them (Pakistan) with intelligence on ETIM locations they give warnings before launching their attacks'; another frets about extremist sympathies in Pakistan's Army, observing that 'we're not worried about the generals, we're worried about the brigadiers'. Pakistan's recent offensive into North Waziristan, home to ETIM's Uzbek allies, the IMU, may dampen these concerns only temporarily. 

The China-Pakistan Axis concludes by connecting the bilateral relationship to broader themes in Chinese foreign policy. On the one hand, Pakistan is both a Chinese pawn (against India) and platform for power projection (Small argues, interestingly, that it's now Chinese naval strategists, not just Indian, who are seriously talking up the long-term possibilities of Pakistan's long-stalled Gwadar port). But there are limits to this approach. For instance, as Small notes, 'Beijing's counterterrorism strategy has been essentially parasitic on the United States being a more important target for transnational militant groups than China'. It's unclear how long that can last.

Nor does China want to shoulder the burden alone. When Osama bin Laden was killed at Abbotabad, the Chinese gratefully took a careful look at the crashed US stealth helicopter but then rejected Pakistan's suggestion of a defence agreement and noted, pointedly, that it 'was not going to backfill for the Americans, and Islamabad urgently needed to patch up its relationship with Washington'. Small's final chapter describes the gradual shift from suspicion towards American bases in the region to growing concern about at a hasty US departure. As the chapter heading reads, 'Lord, make them leave – but not yet'. Such is free-riding. 

The dilemma, suggests Small, is the contrast between Beijing's impatience in the seas to the east, where 'China looks uncomfortably like a bully', and its caution in the west, where 'Beijing has sat passively watching developments in the region that are inimical to its interests'. This volume makes a credible case that China is likely to respond to these challenges not by cutting Pakistan loose, as India might hope, but by deepening an admittedly complex relationship with its only real friend in the world. The question is whether the areas of growing friction will be more serious than in previous post-American spells.