But the Chancellor also underlined the UK’s strong desire for agreement.
And he said there would be interim arrangements to cover any details of Britain’s departure that had not quite been sorted out when the two-year deadline loomed.
Theresa May expects to trigger up to two years of formal talks with the rest of the EU when she invokes Article 50 of the Lisbon Treaty by the end of March this year.
'We would reinvent ourselves' Hammond tells European Union leaders
She wants a good partnership with the EU but warned this week that she will walk away with no deal rather than settle for a bad one.
Our ambition is to have the deal wrapped up within the two-year time frame
Downing Street spokesman
Today Downing Street insisted it remained the Government’s aim to agree terms in the two years.
A spokesman said: “Our ambition is to have the deal wrapped up within the two-year time frame that is allotted by Article 50, but we have been very clear that there would then follow, if necessary, implementation phases across various sectors."
Speaking in Davos, Switzerland, at the World Economic Forum of political and business leaders, Mr Hammond insisted he had not in recent remarks about making the UK a low tax haven if the EU shut us out of its markets been “threatening” fellow governments.
Theresa May is expected to trigger Article 50 in March this year
He told his audience: “It shouldn’t be a surprise for anyone to hear that our first duty as an elected Government is to protect the living standards of our people and that means the competitiveness of our economy.
“And, if we were to be, by some catastrophe, closed off from those markets we would have to reinvent ourselves.
Get Quotes on Home Insurance
“We would have to find another model, another way to earn our living, to remain competitive in the world.
“I just want to send out a clear message that we’ve reinvented ourselves before. The City of London now looks radically different to the City of London in the 1970s.
“We can reinvent ourselves, we can reinvent our institutions and we will do so if we have to but our clear preference is to remain in that mainstream.”
He added that it was a “political necessity” for Britain to quit at the end of the two years.
Mr Hammond said: “If we are making good progress but haven’t quite got there we will simply agree that Britain will leave the EU and we will agree some interim arrangements while we complete the discussion.
Philip Hammond was speaking in Davos, Switzerland, at the World Economic Forum
“But we think it can be done in two years if there is a political will on both sides to reach agreement on our exit and at least agreement on the broad principles of the end state that will exist between the UK and the EU.”
He also stressed there would be “many transitions” involved in actually leaving, including new border infrastructure if customs arrangements changed and “significant new IT systems” to police new migration rules.
“These cannot be built and deployed in a few months. They are going to take years in some cases.”
Some companies were “understandably” postponing investment decisions until “the fog of Brexit” lifted and the future became clearer.
But he stressed: “The UK economy has been resilient in 2016, confounding many sceptics who believed that we would face an immediate and negative response in the economy to the Brexit referendum.
“We end 2016 as the fastest-growing of the large developed economies.”
German finance minister Wolfgang Schauble
May's Brexit speech: Europe reacts
Tue, January 17, 2017
Politicians and celebrities tweet their reaction as Theresa May unveils her 12 point plan for Britain leaving the EU.
1 of 9
The British Prime Minister Delivers Her Brexit Speech
He pointed to strong consumer demand and how the falling pound had made the UK “a buying opportunity” for foreign companies and investors, although he agreed Britain could also expect higher inflation this year.
He added that “could” be discussion of preferential migration access for Europeans although Britain had made clear it would not accept a continuation of uncontrolled free movement.
Speaking alongside him in Davos, German finance minister Wolfgang Schauble said his country would do “whatever we can” to ensure a successful outcome to Brexit talks within two years.
A “cliff-edge” Brexit without a deal would be a disaster for the UK and Europe, said Mr Schauble.
He played down fears of Britain becoming a Singapore-type offshore low-tax haven, and said he expected the UK to remain an important EU partner and London a major financial hub.