Egyptian President Abdel Fattah al-Sisi visited the country's top cathedral to pay his condolences to Coptic Pope Tawadros II and the Christian community, a day after Islamic State released a video showing the beheading of 21 Egyptians in Libya.
Egyptian Prime Minister Ibrahim Mehleb and Interior Minister Mohamed Ibrahim accompanied al-Sisi on his visit.
David Cameron has said Libya must not be allowed to become a "safe haven for terrorists" as he condemned the "barbaric" murder of 21 Egyptian Coptics by Islamic State (IS).
The Prime Minister added: "I am appalled by the murder of Christians in Libya, a simply barbaric and inhumane act. My thoughts are with the families of those killed and the UK stands united with the Egyptian people during this period of mourning.
"Our efforts to defeat the monstrosity of Islamist extremism must not waver.
"The UK remains steadfast in its efforts to defeat Isil and in its work to bring about a political transition in Libya through the UN. We are clear that Libya must not become a safe haven for terrorists."
A Downing Street spokeswoman said the UK was "discussing with Egypt at the moment exactly what action they are taking" in Libya after airstrikes were launched by the country in response to the murder of 21 Egyptian Christians by Islamic State (IS).
The spokeswoman said the murder of Egyptian nationals by IS "underlines in Libya the importance of finding a political solution. The Prime Minister has appointed a special envoy on Libya to work with UN partners and representatives in Libya to work on a way forward on that".
"It is absolutely clear that what we need to be doing around the world is working with other countries to tackle this growing threat from Islamist extremists and their poisonous ideology wherever we find it," said the spokeswoman.
When asked whether Britain could offer Cairo military support, she said: "Our focus is on the political solution and there are no discussions beyond that at the moment in Government."
Pope Francis has denounced the slaying of Egyptian Copts in Libya by Islamic State (IS), saying they were "assassinated just for being Christian".
Francis spoke off-the-cuff during an audience with a Scottish ecumenical delegation.
He said: "They only said 'Jesus help me ...' The blood of our Christian brothers is testimony that cries out. Be they Catholic, Orthodox, Copts, Lutherans, it doesn't matter. They're Christian."
The killings have raised anxieties in Italy, given Libya's proximity just across the Mediterranean Sea and because one of the militants in the video said the group plans to "conquer Rome," the seat of Catholicism.
A spokesperson for Libya's Tripoli-based Parliament has said Egyptian airstrikes in Libya are an assault on the country's sovereignty.
The spokesman for the General National Congress, Omar Homaydan, said: "We strongly condemn the Egyptian aggression this morning on Derna which we consider to be an assault against Libyan sovereignty," .
The Archbishop of Canterbury has condemned terror attacks in Libya, Denmark and Nigeria in recent days, calling for "deep compassion for the bereaved and killed".
The Most Rev Justin Welby called the beheading of Christian hostages in Libya by Islamic State (IS), shootings in Denmark and a suicide bombing in Nigeria "terrible cruelty".
The killers seem to rejoice in ever more extreme acts carried out to inflict ever greater terror. We must all weep with those affected, and know that in the love of Christ all evil will be overcome.
In Egypt and Libya, the home of Christian faith, of saints and martyrs since the earliest centuries, more suffering has been perpetrated. The Coptic church has responded with courage and as always with faith.
The darkness which Isis seek to spread will be overwhelmed by the faithful lives of Christians shedding the light and peace of Christ. I have been in touch with the Anglican Church in Egypt to express solidarity.
Let us pray for the triumphant peace of Christ to be evident, and for governments affected to be wise and courageous."
Egypt called on the U.S.-led coalition fighting Islamic State in Syria and Iraq to confront militants in Libya, a day after the group released a video showing the beheading of 21 Coptic Christian Egyptians there.
Referring to IS by the Arabic acronym Daesh the Foreign Ministry said in a statement: "Egypt renews its call for the international coalition against the Daesh terrorist organisation...to take the necessary measures to confront the terrorist Daesh organisation and other similar terrorist organisations on Libyan territories".
French President Francois Hollande and Egyptian President Abdel Fattah al-Sisi have called for a UN Security Council meeting to discuss the security situation in Libya after Egypt's military launched air strikes against Islamic State targets there.
The strikes came hours after the apparent beheadings of 21 Egyptian Christians in Libya.
"They underscored the importance of the (U.N.) Security Council meeting and of the international community taking new measures to face up to the danger" of the Islamic State, Hollande's office said after the two leaders' telephone conversation.
A Libyan Air Force commander said 40-50 militants were killed in airstrikes on Islamic State targets in the country, according to Egyptian state television.
Saqer al-Joroushi said: "There are casualties among the individuals, ammunition and the communication centres belonging to them. The number of deaths are not less than 40 or 50 for sure".
French President Francois Hollande has condemned the "savage" killing of 21 Egyptians in Libya by Islamic State and said France and its allies were determined to fight the militants.
Mr Hollande condemned the killings by Daesh, his office said in a statement, using an acronym for Islamic State.
"He expresses his concern about the extension of Daesh operations in Libya and reminds of the determination of France and its allies to fight against this group," his office said.