The beheadings were described as "barbaric" by al-Azhar, the highly regarded theological institution which is based in Egypt.

The Coptic church said it was "confident" Egypt would exact retribution. Egypt has declared seven days of national mourning.

Libya has been in turmoil since 2011 and the overthrow of its then-leader, Col Muammar Gaddafi.

Since then, numerous other militia groups have battled for control.

The head of the US Defense Intelligence Agency warned last month that IS was assembling "a growing international footprint that includes ungoverned and under-governed areas", including Libya.

Analysis - Orla Guerin, BBC News, Cairo

The five-minute video shows hostages in orange jumpsuits being marched along a beach, each accompanied by a masked militant. The men are made to kneel before they are simultaneously beheaded.

Most were from a poor village in Upper Egypt where some relatives fainted on hearing the news. A caption accompanying the video made it clear the hostages were targeted because of their faith. It referred to the victims as "people of the cross, followers of the hostile Egyptian church".

There's speculation here that Egypt may now consider airstrikes across the border. President Abdel Fattah al-Sisi has said in the past that militants in Libya are a danger not just to Egypt, but also to the Middle East.

Rival governments

Libya has two rival governments, one based in Tripoli, the other in Tobruk. Meanwhile, the eastern city of Benghazi, headquarters of the 2011 revolution, is largely in the hands of Islamist fighters, some with links to al-Qaeda.

On Sunday, Italy closed its embassy in Tripoli. Italy, the former colonial power, lies less than 500 miles (750km) from Libya at the shortest sea crossing point.

Italian Premier Matteo Renzi has been calling for the UN to intervene in Libya. Thousands of migrants use the Libyan coast as a starting point to flee the violence and attempt to reach the EU.

UK Foreign Secretary Philip Hammond condemned the beheadings.

"Such barbaric acts strengthen our determination to work with our partners to counter the expanding terrorist threat to Libya and the region," he said.

On Sunday, President Sisi banned all travel to Libya by Egyptian citizens.

Despite the turmoil in Libya, thousands of Egyptians go to the country looking for work.

There had been demonstrations in Egypt calling on the government to do more to secure the release of those held.