Once, when flying from India to the UK, I left my passport on the plane's seat-back pocket and forgot that I left it there until I reached the passport control desks. Fortunately in this case, I rushed back to the gate where the plane had parked and since the plane was being cleaned there, I was able to request the staff to fetch my passport for me from my seat.
My question is: what happens if you lose your passport during transit at an airport, or before you reach the passport control desk at your destination country? I know that in any other situation, I would be able to contact my country's embassy to get an emergency travel document (ETD). What happens in this other case - can you get an ETD at the airport, or will you be deported back to the country you flew from? And in case of a deportation, are you sent back to your home country or the origin country of your previous flight? I want to know if there are any international laws covering this scenario.
(This is all under the assumption that you have the relevant visas or travel authorisation for your destination, but they're obviously in your passport.)