A video has emerged showing the beheadings purportedly of 21 Egyptian Christians who had been kidnapped by Islamic State (IS) militants in Libya.
The footage shows a group wearing orange overalls, being forced to the ground and then decapitated.
Egypt reserves the right to respond in any way it sees fit, its President Abdel Fattah al-Sisi has said.
IS militants claim to have carried out several attacks in Libya, which is in effect without a government.
However, with many armed groups operating in Libya, it is not clear how much power IS actually wields.
The kidnapped Egyptian workers, all Coptic Christians, were seized in December and January from the coastal town of Sirte in eastern Libya, now under the control of Islamist groups.
The video of the beheadings was posted online by Libyan jihadists who pledge loyalty to IS. A caption made it clear the men were targeted because of their faith.
"Egypt and the whole world are in a fierce battle with extremist groups carrying extremist ideology and sharing the same goals," President Sisi said.
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.
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.
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.