Beijing has lodged a formal complaint with Pyongyang after a North Korean army deserter sneaked across the border and killed four Chinese villagers with a handgun.

While relations between isolated North Korea and China, its only significant ally, have grown strained in recent years, violent conflict along their 1,420km-long shared border is rare.

The 26-year-old soldier crossed the Tumen river from North Korea into north-eastern China’s Jilin province at about 7.30am on 27 December, South Korea’s Dong-A Ilbo newspaper and Yonhap news agency reported, citing an anonymous source.

The soldier broke into the home of a 60-year-old ethnic Korean villager surnamed Xu and shot the man and his wife, killing them. He then entered the home of Xu’s neighbours – an elderly couple called Li – and beat them to death with his gun.

The soldier then entered a third house, owned by a villager surnamed Che, and stole 100 yuan (£10) and some food.

That night, Chinese soldiers and police shot the soldier in the stomach as he fled to the upper reaches of the Tumen. He remains unconscious in a local hospital.

China’s foreign ministry spokeswoman Hua Chunying confirmed the incident at a press briefing on Monday afternoon, adding that China had “lodged representations” to North Korea and “will handle the case in line with relevant laws.”

Chinese media also reported the incident on Monday, underscoring the awkward, often self-contradicting nature of Beijing’s relationship with its northern neighbour. China has supported North Korea for decades, afraid that instability in Pyongyang could send waves of North Korean refugees streaming across the border.

Yet Chinese authorities also appear wary of the country’s 31-year-old leader, Kim Jong-un. Kim has ruled the country since his father, Kim Jong-il, died in 2011, and his early tenure has been marked by sabre-rattling and repeated nuclear tests.