Doctors Without Borders, known by its French initials, MSF, has suspended its medical activities in the northeastern Nigerian town of Rann after a deadly attack on aid workers by suspected Boko Haram fighters in the area.

The announcement came on Friday, hours after an attack on a military base in Rann, which is located in Borno state, killed at least two aid workers, a doctor and eight members of the security forces.

The military base is near a camp hosting about 55,000 internally displaced persons.

"Following a violent attack ... Medecins Sans Frontieres (MSF) suspended its medical activities in the town and evacuated 22 national and international staff," an MSF statement said.

The fighters involved in Thursday's attack were armed with "automatic weapons, rocket-propelled grenades and gun trucks", according to an official statement by the International Organisation for Migration (IOM).

Al Jazeera's Mohamed Vall, reporting from Abuja, said the target of the attack was the military post guarding the camp but the crossfire between the fighters and security forces resulted in the death of aid workers.

"According to the UN source, two of them [aid workers] had been working with the International Organisation for Migration (IOM), and one was a medical doctor with UNICEF," he said. All three were Nigerian nationals.

"A fourth worker, whose identity has not yet been established, is also suspected to have died and another one was apparently abducted," Vall added.

MSF said about 40,000 people in Rann were relying almost entirely on its healthcare services.

It said its decision to suspend its work in the town was "an extremely painful decision".

"The latest attack is a stark reminder that it is the people in Borno who are paying the price of this ruthless conflict," Kerri Ann Kelly, MSF emergency coordinator in Nigeria, said in a statement.

Thursday's attack came nearly two weeks after Boko Haram fighters abducted 110 girls from a school in the town of Dapchi, west of Rann, in neighbouring Yobe state.

That incident is seen as a major setback for President Muhammadu Buhari who had vowed to improve security and defeat Boko Haram.

Borno state is the part of Nigeria that is worst hit by the Boko Haram attacks, which have continued despite repeated assertions by the government and military since 2016 that they had defeated the armed group.

Boko Haram roughly translates to "Western education is forbidden".

More than 20,000 people have been killed, and over two million have been forced to flee their homes since 2009 when the group waged an armed campaign in northeastern Nigeria.