Nigerian President Goodluck Jonathan has visited the capital of a Nigerian state where Islamic militants from Boko Haram have increased their attacks and seized more territory.

Jonathan's office said in a statement that the president traveled to Maiduguri, the capital of northeastern Borno state, in a "surprise visit" on Thursday and visited troops involved in the fight against the extremists. He also visited hundreds of civilians who were staying in a camp in Maiduguri after fleeing Baga, a town in Borno, after Boko Haram fighters overran an army base there and slaughtered civilians.

Jonathan, who is running for re-election in February, has not visited the northeast since a state of emergency was imposed in May 2014.