U.S. Secretary of States John Kerry said the United States will continue to support the Nigerian military in its fight against Boko Haram.
Kerry, who arrived Sunday in the Nigerian city of Lagos, spoke shortly after Nigerian troops repelled an attack by Boko Haram militants on the outskirts of the Borno state capital of Maiduguri, with a population of about 2 million.
"The principle reason that [U.S.] President [Barack] Obama asked me to come here at this moment is to reinforce to all Nigerians the desire of the United States to be able to engage you even more so in the effort to push back against Boko Haram or any other violent extremist group," Kerry said.
He met with the country's two leading presidential candidates, incumbent President Goodluck Jonathan and main opposition candidate Muhammadu Buhari, ahead of the country's February 14 elections, tipped to be the closest since Nigeria returned to civilian rule in 1999.
Peaceful elections 'absolutely critical'
Kerry said, "It is absolutely critical" the elections are conducted peacefully, that they are credible, transparent and accountable, adding that anyone who perpetuates election violence will not be welcome in the United States.
"Anyone who participates in, plans or calls for widespread systematic violence against the civilian population must be held accountable, including by ineligibility for an American visa," he said, adding, "Violence has no place in democratic elections and I can guarantee you that the perpetrators for such violence will not be welcomed in the United States of America."
President Jonathan said in a statement that he is deeply committed to ensuring that the coming election is "free, fair and credible," adding that it is critical that all parties commit to non-violence, before, during and after the vote.
Kerry announced his trip to Nigeria on Friday at the World Economic Forum in Davos, Switzerland, where he spoke at length on the threat to the world from Islamist extremist groups, including Boko Haram.
On Sunday, soldiers repelled sevearl separate attempts by insurgents to enter the state capital, each attempt from a different direction, according to a security officer in Maiduguri.
Fight for Maiduguri
The fighting began around midnight and continued into the morning. A soldier at the scene told VOA many are dead on both sides.
A military source and a civilian joint taskforce leader confirmed that scores of militants and soldiers were killed in Maiduguri. They did not give a civilian death toll.
Authorities barricaded the roads and imposed a curfew in the city until further notice.
Maiduguri in Borno state, Nigeria
Nigeria's Defense Headquarters said it coordinated air and land operations against the simultaneous attacks.
However, Boko Haram fighters took control of the military barracks in Monguno, 180 kilometers northwest of the capital. Attacks by the militants were also reported Sunday in Adamawa state where deaths, looting and abductions have been reported.
Lagos, the country's financial capital, is about 1,500 kilometers (1,000 miles) southwest of Maiduguri.
Amnesty International stressed the urgency of protecting both cities - in particular the teeming state capital Maiduguri.
"We believe hundreds of thousands of civilians are now at grave risk," Amnesty's Africa director Netsanet Belay said in a statement.
"People in and around Maiduguri need immediate protection. If the military doesn't succeed in stopping Boko Haram's advance, they may be trapped with nowhere else to turn," Belay said.
In a report last week, the Virginia-based Center for Naval Analyses, a federally funded research corporation, called Boko Haram a locally focused insurgency largely fueled by bad government.
"The conflict is being sustained by masses of unemployed youth who are susceptible to Boko Haram recruitment, an alienated and frightened northern population that refuses to cooperate with state security forces, and a governance vacuum that has allowed the emergence of militant sanctuaries in the northeast," the report said.
The Sunni jihadist group Boko Haram has killed thousands during a five-year insurgency to carve out an Islamic state in the northeast of Africa's most populous country.
The army's inability to squash the group is a major headache for Jonathan, who is seeking re-election in February and who visited the state capital on Saturday as part of his campaign. Opposition candidate Buhari had been due to arrive on Monday.
The assault on Maiduguri began just after midnight and that on Monguno later in the morning. Around 9 a.m. (0800 GMT) on Sunday, a Reuters witness in Maiduguri said shelling could be heard and that military helicopters were circling the city.
Soldiers and security block a road as they secure the venue during a rally of the ruling People's Democratic Party (PDP) in Maiduguri, Nigeria, Jan. 24, 2015.
All roads have been closed, a security source said, and commercial activity has been shut down.
The militants began the attack at the edge of the city in the Njimtilo area. Maiduguri is the capital of Borno state and would be a major prize for the insurgents.
The militants control vast swathes of Borno state and some areas of neighboring Adamawa and Yobe states, and recently took control of the town and a multinational army base at Baga by Lake Chad.
Monguno is about 138 kilometers north of the state capital, and just over 50 kilometers from Baga. Security sources said the attack there began on Sunday morning and that the military was overwhelmed by Boko Haram's firepower. Houses in the town were also being set on fire.
"Boko Haram has more power than us and are shelling the town ... our colleagues are fleeing," a soldier in Maiduguri said after speaking to friends fighting the insurgents in Monguno.
Fighting in both towns was intense throughout the day, as Islamist militants fought Nigerian ground troops who were equipped with heavy weaponry and backed by fighter jets, the French news agency AFP reported.
A second attempt to take the city's airport in the afternoon was also repelled, Reuters reported.
Many civilians caught in the violence were people who had previously been displaced to Monguno and Maiduguri after Boko Haram stormed their home town of Baga on January 3, AFP reported.
More than 13,000 people have been killed and more than 1 million made homeless by Boko Haram violence since 2009.
Kareem Haruna contributed to this report from Maiduguri. Some material for this report came from Reuters, AP and AFP.