A dog has died after attacking a suicide bomber who tried to blow herself up at a wedding in Nigeria.

Witnesses said the teenage girl attempted to infiltrate a crowd celebrating near the town of Maiduguri, where Isis affiliate Boko Haram has been waging a bloody campaign to establish a “caliphate”.

Buba Ahmed, from Belbelo village, said the bomber was on the outskirts of the gathering when the dog attacked her on Sunday morning, grappling with her until the explosives detonated and killed them both.

He said guests were grateful to the pet, which they felt had “sacrificed itself to save their lives”.

Borno state police confirmed the incident, which came hours after three suicide bombers were killed in attacks foiled in nearby towns.

A multinational force has driven Boko Haram jihadis out of most towns and villages in north-eastern Nigeria, but the extremists have resorted to attacking soft targets with suicide bombers.

The rise of Boko Haram Show all 20 1 /20 The rise of Boko Haram The rise of Boko Haram Boko Haram The leader of the Islamist extremist group Boko Haram Abubakar Shekau delivers a message. Boko Haram has claimed responsibility for the mass killings in the north-east Nigerian town of Baga in a video where he warned the massacre “was just the tip of the iceberg”. As many as 2,000 civilians were killed and 3,700 homes and business were destroyed in the 3 January 2015 attack on the town near Nigeria's border with Cameroon AFP The rise of Boko Haram Boko Haram People displaced as a result of Boko Haram attacks in the northeast region of Nigeria, are seen near their tents at a faith-based camp for internally displaced people (IDP) in Yola, Adamawa State. Boko Haram says it is building an Islamic state that will revive the glory days of northern Nigeria's medieval Muslim empires, but for those in its territory life is a litany of killings, kidnappings, hunger and economic collapse The rise of Boko Haram Boko Haram Nitsch Eberhard Robert, a German citizen abducted and held hostage by suspected Boko Haram militants, is seen as he arrives at the Yaounde Nsimalen International airport after his release in Yaounde, Cameroon on 21 January 2015 The rise of Boko Haram Boko Haram Officials of the Nigerian National Emergency Management Agency (NEMA) visit victims of a bomb blast in Gombe at the Specialist Hospital in Gombe. According to local reports at least six people were killed and 11 wounded after a bomb blast in a marketplace in Nigeria's northeastern state of Gombe on 16 January 2015. Islamist militant group Boko Haram has been blamed for a string of recent attacks in the North East of Nigeria The rise of Boko Haram Boko Haram People gather at the site of a bomb explosion in a area know to be targeted by the militant group Boko Haram in Kano on 28 November 2014 The rise of Boko Haram Boko Haram People gather to look at a burnt vehicle following a bomb explosion that rocked the busiest roundabout near the crowded Market in Maiduguri, Borno State on 1 July 2014. A truck exploded in a huge fireball killing at least 15 people in the northeast Nigerian city of Maiduguri, the city repeatedly hit by Boko Haram Islamists The rise of Boko Haram Boko Haram President Goodluck Jonathan visits Nigerian Army soldiers fighting Boko Haram Getty Images The rise of Boko Haram Boko Haram Displaced people from Baga listen to Goodluck Jonathan after the Boko Haram killings AFP/Getty The rise of Boko Haram Boko Haram Nigeria's President Goodluck Jonathan speaking to troops during a visit to Maiduguri, the capital of Borno State; most of the region has been overrun by Boko Haram AFP/Getty The rise of Boko Haram Boko Haram Members of the Nigerian military patrolling in Maiduguri, North East Nigeria, close to the scene of attacks by Boko Haram EPA The rise of Boko Haram Boko Haram Boko Haram’s leader, Abubakar Shekau, appears in a video in which he warns Cameroon it faces the same fate as Nigeria AFP The rise of Boko Haram Boko Haram Nana Shettima, the wife of Borno Governor, Kashim Shettima (C) weeps as she speaks with school girls from the government secondary school Chibok that were kidnapped by the Islamic extremist group Boko Haram, and later escaped in Chibok The rise of Boko Haram Boko Haram South Africans protest in solidarity against the abduction of hundreds of schoolgirls in Nigeria by the Muslim extremist group Boko Haram and what protesters said was the failure of the Nigerian government and international community to rescue them, during a march to the Nigerian Consulate in Johannesburg The rise of Boko Haram Boko Haram Boko Haram militants have seized the town in north-eastern Nigeria that nearly 300 schoolgirls were kidnapped from in April 2014 AFP The rise of Boko Haram Boko Haram A soldier stands guard in front of burnt buses after an attack in Abuja. Twin blasts at a bus station packed with morning commuters on the outskirts of Nigeria's capital killed dozens of people, in what appeared to be the latest attack by Boko Haram Islamists, April 2014 The rise of Boko Haram Boko Haram The aftermath of the attack, when Boko Haram fighters in trucks painted in military colours killed 51 people in Konduga in February 2014 AFP/Getty Images The rise of Boko Haram Boko Haram The leader of Boko Haram, Abubakar Shekau (with papers) in a video grab taken in July 2014 AFP/Getty The rise of Boko Haram Boko Haram Ruins of burnt out houses in the north-eastern settlement of Baga, pictured after Boko Haram attacks in 2013 AP The rise of Boko Haram Boko Haram A Boko Haram attack in Nigeria, 2013 AFP/Getty Images The rise of Boko Haram Boko Haram Abubakar Shekau, Boko Haram’s leader AP

Unlike its parent group Isis, it frequently uses women for the attacks, with those who manage to escape the terrorist group claiming they were paid or kidnapped and forced.

An 18-year-old woman who was stopped while wearing an explosive vest in Maiduguri in February said she had been given N200 (50p) for food by militants who instructed her to “detonate the explosives anywhere we saw any form of gathering”.

“They said if we press the button, the bomb would explode and we will automatically go to heaven,” said Amina, who had been abducted by Boko Haram two years before.

Nigerian troops and militias have prevented dozens of suicide bombings in recent months through increased security at checkpoints, along with body searches outside targets like marketplaces and mosques, but dozens have been killed.