ISIOLO, Kenya (Reuters) - An expelled student shot dead six of his former schoolmates and a security guard at his school in northern Kenya on Saturday, and was then himself lynched by a furious mob, officials said.

The attack took place at a school in the remote town of Lokichogio in Kenya’s Turkana region, close to the border with war-torn South Sudan. At least six other students were flown to hospital with bullet wounds.

The assailant was a 17-year-old from South Sudan - one of thousands of refugee children who have been living in Kenya and going to school there since civil war broke out in their country in 2013. He was detained in possession of an AK-47, the basic assault rifle of choice in conflicts across Africa and the Middle East.

“The school was not attacked by bandits but an errant student on expulsion for disciplinary cases,” regional government official Wanyama Musyambohe told reporters.

Security officials said the assailant, whose name has not been disclosed, had been arrested, but then killed by a mob while in police custody.

“The attack ... is a painful reminder of the state of insecurity along the border,” tweeted Turkana county governor Josphat Nanok.

Close to 2 million people have fled South Sudan since fighting broke out in December 2013, sparking what has become Africa’s largest cross-border exodus since the 1994 Rwandan genocide. Some 75,000 of them are now in Kenya.

Perennial conflicts have left the region awash with arms, which are smuggled across borders with relative ease.