MAIDUGURI, Nigeria (Reuters) - Hundreds of people in northeast Nigeria who fled a town targeted by militants linked with Islamic State have sought refuge in capital of Borno state, Reuters witnesses said on Saturday.

Slideshow ( 3 images )

An uptick in attacks by Islamists and the resulting upheaval in the region comes in the run up to an election in which President Muhammadu Buhari will seek a second term. Security has become a campaign issue following a series of attacks.

A faction of Boko Haram, Islamic State in West Africa (ISWA), which split from the insurgency in 2016 claimed responsibility for an attack on a military base in Baga, a town in eastern Borno state, which the Nigerian army said took place on Wednesday evening.

The fight to control Baga - a strategic town as it borders Nigeria, Niger, Chad and Cameroon - forced hundreds to seek safety in Maiduguri, some 200 km (124 miles) to the south.

Reuters witnesses saw hundreds of people arriving in Maiduguri and gathering at a bus terminus on the outskirts of the city.

“In Baga, we are in Boko Haram hands because yesterday they were going around with their machine [guns] and motor [vehicles],” Baga resident Abdul Kami said on Saturday, describing the attack on the town.

Residents on Friday said at least 10 people were killed in the attack on Baga.

The Boko Haram insurgency, which Buhari vowed to end when he took office in 2015, aims to create an Islamic state in northeast Nigeria. It has forced about 2.7 million people to flee their homes since 2009 and killed around 30,000.

The military and insurgents also clashed in Monguno, a town in the adjacent local government authority to Baga.

But Islamic State, in a statement issued through its news agency Amaq, said its fighters “killed and injured dozens, took four apostates as captives, burned many barracks, and seized weapons and ammunition”.

Critics of Buhari have pointed to attacks in the last few weeks to criticize the former general’s security record. In particular, they highlighted the attack on an army base in Metele, Borno state in which about 100 soldiers were killed.

Attacks by Boko Haram in the run-up to the last election in 2015 weakened then-president Goodluck Jonathan and helped Buhari to defeat him at the polls.