Hong Kong (CNN) Beijing is on the verge of being sucked into an India-Pakistan crisis, amid rising tensions in the Kashmir region that borders China.

Diplomatic relations between longtime rivals India and Pakistan reached their lowest point in years this week, after Pakistan claimed its air force shot down two Indian jets over the disputed border Kashmir region, capturing one pilot.

That came a day after the Indian military said it had launched airstrikes against a terrorist camp in Pakistan, the first such incursion by Indian air forces since the India-Pakistan war of 1971.

It isn't just that China shares a border with the contested region of Kashmir -- Beijing also has important links with both Pakistan and India that it needs to balance.

China has close economic, diplomatic and military ties with Pakistan, making it one of the nation's closest allies in region.

China's President Xi Jinping shakes hands with Pakistan's Prime Minister Imran Khan on November 2.

Meanwhile, China's long-running trade war with the US has forced Beijing to look for alternative trading partners. As result, China has started to rebuild ties with rival rising power India and Prime Minister Narendra Modi. Last year Modi made two visits to China.

This week, China's Foreign Ministry called for both Pakistan and India to "maintain self-restraint and focus on regional peace and stability."

In an urgent late night call on Wednesday, Pakistan Foreign Minister Shah Mehmood Qureshi asked Chinese Foreign Minister Wang Yi to play "a constructive role in easing the current tensions."

During the call, China's Foreign Minister Wang Yi stressed that "the sovereignty and territorial integrity of all countries should be respected, and China does not want to see the acts that violate the norms of international relations."

Steve Tsang, director of the China Institute at SOAS University of London, said there was no benefit to China on any front if tensions between India and Pakistan spiraled.

"China cannot afford to be seen as failing Pakistan, but at the same time I don't think the Chinese really want to pick a fight with the Indians over this," he said.

The Xinjiang dilemma

The long-standing tensions that existed in the region were not a big problem for Beijing, according to China expert Tsang, as they served to remind Islamabad of China's importance as an ally.

But the escalation this week has put Beijing in an awkward position.

"They have to do something to show that they are helping to keep things under control, while not appearing unreliable as Pakistan's ally," Tsang said.

But Beijing doesn't want to overplay its support of Pakistan and push India into the arms of US President Donald Trump.

Compounding China's problems is the fact India claims it was striking back against terrorists in Kashmir.

The mass detention of Muslim majority Uyghurs in China's north western province of Xinjiang by the Chinese government is one of Beijing's most controversial international policies -- and justified by China's government on the grounds that it is an essential measure in combating terrorism.

"They don't want to be too hard on India, because they're acting in response to terrorism," Tsang said.

China experts said the country's best option was to join the US in working to defuse tensions between Pakistan and India.

Han Hua, professor and South Asia studies expert at Peking University, said given China has greater influence in Pakistan, while the US holds more sway in India, it made sense for the two to cooperate.

"China's message is clear to both sides: exercise restraint," she said. "China's interest lies in the stability of South Asia."

Beijing's South Asian tightrope

China has been pulling off a delicate diplomatic balancing act in South Asia in the past year, after easing some regional tensions.

In July 2017, for example, there was a heated month-long territorial standoff between Chinese and Indian troops in Doklam, near the borders of India, China and Bhutan.

The two powers nearly came to blows over accusations the Chinese government was building a road inside the territory of close Indian ally Bhutan.

Nearby, China also conducted live-fire drills with combat troops.

But a warm, informal summit between Chinese President Xi Jinping and Indian Prime Minister Narendra Modi in April 2018 helped put relations back on a positive track.

"The common interests of China and India far outweigh their differences," state-run newspaper China Daily said in an editorial at the time.

The situation is much clearer for China across the border. Pakistan is a longtime friend and trading partner of Beijing, described by Chinese diplomats as enjoying an "all-weather friendship" with the country.

Pakistan is also one of the largest buyers of Beijing's weapons. Between 2008 and 2017, Islamabad purchased more than $6 billion of Chinese arms, according to think tank CSIS.

It hasn't all been easy sailing, however. Questions have been raised about the large debts Pakistan has accrued as a result of Chinese government loans and infrastructure.

But Pakistan Prime Minister Imran Khan has been determined to keep the special relationship with Beijing strong. "We need to use China as an inspiration to lift our people out of poverty," he said.