Islamist militant group al-Shabab has claimed responsibility for a bomb attack which blew a huge hole in the side of a plane in Somalia.

The al-Qaeda affiliated group, based in Somalia, released an emailed statement claiming the attack was revenge for Western intelligence operations in the African country.

But the group admitted it had failed in its aim of bringing down the aircraft.

The Daallo Airlines plane, which took off from Somalia's capital bound for Djibouti on February 2, landed back in Mogadishu despite the blast, which Somali authorities say was caused by a laptop computer containing a bomb.

It blew a one-metre sized hole in the plane's fuselage.

Authorities in Somalia said the explosion killed the suspected bomber.

Investigators believe the attack was carried out by a Somali national, who carried the laptop computer with a bomb in it onto the flight.

The explosion happened about 15 minutes into the flight, when the plane was only at around 11,000ft (3,350m) and the cabin was not yet pressurised.

The bomb could have triggered a secondary explosion in the fuel tank if the aircraft had reached cruising altitude, according to experts.

Most of the plane's passengers had originally been booked on a Turkish Airlines flight.

However, that flight was cancelled due to bad weather a few hours before take-off, Turkish Airlines said.

In its statement, al-Shabab said it had targeted Turkish Airlines because it said the Nato state was supporting Western operations in Somalia.

Al-Shabab said the operation targeted "Western intelligence officials and Turkish NATO forces aboard the airplane bound for Djibouti."

The statement said: "While the operation did not bring down the plane as Allah had decreed, it struck terror in the hearts of the crusaders."

The group vowed to continue targeting "Western intelligence teams" that operate in Somalia.

The statement called the bombing "retribution for the crimes committed by the coalition of Western crusaders and their intelligence agencies against the Muslims of Somalia."

It said the attack was intended to stop "the flow of Western crusaders into this Muslim land".

Somali authorities have released a video showing a passenger being given a laptop that they believe contained the bomb.

In the video, a man in an orange high-visibility vest is shown walking with a man in a blue shirt holding what looks like a laptop. Another man in a hat approaches them and it is alleged that the laptop is handed over.

More than 20 people have been arrested in connection with the incident, the Somali government said.

Al-Shabab, which is banned as a terrorist group by both the US and the UK and is believed to have between 7,000 and 9,000 fighters, has been linked to some of worst violence in recent years in and around Somalia.

Last year's massacre at Garissa University near the border with Somalia, is the bloodiest so far.

At least 147 people died when gunmen stormed the university at dawn and targeted Christian students on April 2.

Previously the worst attack was on Nairobi's Westgate shopping centre in 2013, when at least 68 people died.

In Westgate, and other attacks, the militants spared Muslims, while killing those unable to recite verses from the Koran.

The terrorist group also claimed responsibility for last month's attack on popular beachside restaurant in Mogadishu.

The gunmen had approached the restaurant from Lido beach, firing at diners on January 21. Authorities said 20 people were killed and several others were injured.

Militants also detonated two car bombs nearby.

There are also regular gun and grenade attacks attributed to al-Shabab both in border areas, where many Kenyans are ethnic Somalis, and in Nairobi.

Kenya has sent its troops into Somali territory, where they have joined the African Union force battling the militants.