The United Nations says unidentified gunmen attacked the headquarters of the UN peacekeeping force in the northern Mali city of Timbuktu, killing seven people and injuring seven others.

The UN peacekeeping mission says six assailants also were killed by UN peacekeepers in the attack on Monday afternoon.

The mission says five Malian security guards and a Malian contractor working for the mission were killed along with a member of the Malian gendarmerie.

UN deputy spokesman Farhan Haq said earlier on Monday that unidentified gunmen attacked two neighbouring UN camps in Douentza in the Mopti region of central Mali, killing one Malian soldier and one UN peacekeeper. Two assailants also died in those attacks.

The mission, known as MINUSMA, said it dispatched a quick reaction force and attack helicopters to secure the Timbuktu headquarters

READ MORE: On the road with Niger's peacekeepers in Mali

"I do not have enough words to condemn this cowardly and despicable act which takes place a few hours after the terrorist attack in Douentza," Mahamat Saleh Annadif, head of MINUSMA, said in a statement.

Antonio Guterres, UN secretary general, condemned the attack and stressed that attacks targeting UN peacekeepers "may constitute war crimes under international law," a spokesman said.

The peacekeeping mission in Mali is the deadliest of the UN's 16 global peacekeeping operations, and this was one of the worst losses of mission staff.

Following a 2012 military coup in the West African country, an armed rebellion took control of Mali's north.

The conflict prompted French military intervention in January 2013 and the deployment of a 12,000-strong UN peacekeeping operation, known as MINUSMA, several months later.

Since the mission began, there have been at least 128 fatalities of MINUSMA staff.

Armed fighters killed three UN peacekeepers in an attack outside their base in Kidal in northern Mali in June.