Britain could crack down on immigration from countries like Greece if the eurozone crisis escalates further, David Cameron has signalled.
The Prime Minister said contingency plans were in place and he would do "whatever it takes" to protect the UK.
The comments came as he appeared before the influential Commons Liaison Committee.
Asked about the danger that Britain could be seen as a safe haven for migrants if the currency area collapsed, Mr Cameron replied: "We obviously have contingency plans for all sorts of different eventualities. That is the right thing for a government to do when there is so much uncertainty."
He went on: "I think the legal position is that if there are extraordinary stresses and strains it is possible to take action to restrict migratory flows. But obviously we hope that does not happen."
Pressed on whether he was ready to tighten border restrictions for troubled states such as Greece, the premier said: "I would be prepared to do whatever it takes to keep our country safe, to keep our banking system strong, to keep our economy robust.
"At the end of the day as prime minister that is your foremost duty.
"I hope it wouldn't come to that but as I understand it the legal powers are available if there are particular stresses and strains.
"You have to plan, you have to have contingencies, you have to be ready for anything with so much uncertainty in our world.
"But I hope these things do not become necessary."