ABUJA (Reuters) - Islamic State’s West Africa branch claimed responsibility on Wednesday for a raid in Nigeria two days earlier in which it said 20 soldiers had been killed, and released a video purporting to show the execution of nine other Nigerian soldiers.

A security source and a humanitarian worker, both requesting anonymity because they were not allowed to speak to media, said insurgents struck the northeastern town of Gubio in Borno state on Monday evening, in vehicles mounted with heavy machine guns and on motorbikes.

The insurgents and soldiers exchanged fire for more than an hour before the army withdrew, said the humanitarian worker, who counted the corpses of more than 15 soldiers.

A Nigerian military spokesman said he would send a comment on the Islamic State claim, but at the time of writing had not.

Nigeria has said the insurgency, and its rival Boko Haram, are on the back foot, as the sides engage in a battle of propaganda to show who has the upper hand in the decade-long conflict.

The war has killed more than 30,000 people and displaced millions more.

The Islamic State branch said in its claim of responsibility, translated into English and published by SITE Intelligence, that its fighters had attacked an army barracks and killed 20 soldiers in Gubio on Monday.

In a separate video also released on Wednesday, Islamic State West Africa showed the execution of nine Nigerian soldiers. It was not immediately possible to independently verify the video.

Before their executions, the soldiers identified themselves by their military service numbers, units and names. Some said where and when they had been captured. For others, it was not immediately clear.

The video also showed Islamic State fighters pledging allegiance to the group’s leader Abu Bakr al-Baghdadi, along with artillery, tanks and boats it said it had captured from the military and attacks on Nigerian bases.

Islamic State West Africa have made several claims of responsibility for attacks over the past months, which have often been verified by security sources and other people with knowledge of their attacks.