The prime minister has told British nationals in Lebanon to "leave immediately" after fighting intensified between Israel and Hezbollah, the Iran-backed armed group which dominates the country.
Sir Keir Starmer said "we are ramping up the contingency plans” and warned that "we are potentially at a brink" of all-out war.
The Ministry of Defence (MoD) is sending 700 troops to nearby Cyprus to prepare for the possible evacuation of British nationals from Lebanon and the government "continues to advise against all travel to Lebanon".
Britons have been advised to book flights out of the country - but there are limited options available, with most airlines except the national carrier having cancelled flights and ceased operating and reports that those remaining are full.
The situation in the country, where Israeli strikes reportedly killed more than 560 people this week, is described as deteriorating "rapidly, with devastating consequences".
Lebanon’s health minister has told the BBC what is happening in his country is “carnage”, as hospitals struggle to cope with the number of casualties from two days of widespread Israeli air strikes targeting Hezbollah.
Asked by reporters how the British prime minister would ensure the situation wasn’t a repeat of the chaos in the Afghan capital Kabul when the Taliban seized control in August 2021, Sir Keir said: "The most important message from me to British nationals in Lebanon is to leave immediately.
"It is important that we’ve been really, really clear: now is the time to leave.”
The handling of the Afghan evacuation, where 15,000 people were airlifted out of the country, was widely criticised as mismanaged and chaotic.
An estimated 10,000 UK citizens are currently in Lebanon. A senior government source said that the difference, for now at least, was that there were still commercial flights leaving Lebanon and British nationals should book a seat.
US citizens have also been told to leave the country. The US Embassy in Lebanon said that most airlines had suspended or cancelled flights with many flights sold out, and urged people to book any ticket available.
Almost every airline operating in Lebanon has stopped flying in and out of the country except for the national airline, Middle East Airlines (MEA).
Alistair, a British national who is married to a Lebanese woman and living in Beirut, said that day-to-day life was mainly carrying on as normal.
Asked about the intensification of the conflict, he told BBC's PM programme: "It's a different level isn't it?"
He urged diplomats to "get a deal made so the violence ceases" and to "bring peace because the ordinary folks here are just recipients of whatever is dealt out".
The 700 British troops deployed to Cyprus will join 500 military personnel who were sent there over the summer as part of the MoD's contingency plans for an evacuation operation.
Two British warships are already in the region and Royal Air Force planes and helicopters on standby.
Asked by BBC Radio 4's Today programme if he sensed the world was on the brink of all-out war in the Middle East, Sir Keir said he was “deeply concerned”.
He said he “put it in those terms, that we are potentially at a brink point, and we have to come back from the brink”.
He repeated his call for an immediate ceasefire and de-escalation, along with other ministers.
Defence Secretary John Healey said: “We continue to urge all sides to step back from conflict to prevent further tragic loss of life.
"Our government is ensuring all preparations are in place to support British nationals should the situation deteriorate.
"I want to thank the British personnel who are deploying in the region for their commitment and professionalism.”
Healey held a meeting with fellow ministers, intelligence chiefs and diplomats on Tuesday afternoon to work through the government’s plans.
Officials say the UK already has a significant diplomatic and military presence close to Lebanon, including RAF Akrotiri in Cyprus and two Royal Navy ships - RFA Mounts Bay and HMS Duncan - which have been in the eastern Mediterranean over the summer.
The Royal Air Force also has planes and helicopters on standby.
The escalating conflict in the Middle East is likely to be a significant topic of discussion for the prime minister and other world leaders at the UN General Assembly in New York.
Sir Keir arrived in the city on Tuesday evening local time.
Tensions have been growing across the Middle East since Hamas gunmen attacked Israel on 7 October last year, killing about 1,200 people and taking 251 others as hostages.
The Israel military campaign in Gaza in response to the Hamas attack has killed more than 41,000 people, according to the Hamas-run health ministry.
Previously sporadic fighting between Israel and Hezbollah escalated on 8 October - the day after Hamas's unprecedented attack. Hezbollah fired at Israeli positions, in solidarity with Hamas.
Hezbollah has launched more than 8,000 rockets at northern Israel and the Israeli-occupied Golan Heights. It has also fired anti-tank missiles at armoured vehicles and attacked military targets with explosive drones.
Last week Hezbollah’s communication devices started exploding all across Lebanon.
Israel then launched a massive series of air strikes on Monday that have so far killed 560 people according to the Lebanese government.
Last year, the British government helped co-ordinate the evacuation of British nationals from Gaza, with some 200 UK citizens thought to be living in the territory before the war broke out.
Additional reporting by Jessica Rawnsley