After a weekend of burning the midnight oil, British and Irish officials amazed everyone here on Monday morning by producing an agreement which seemed to do the impossible. It guaranteed that the present invisible Irish border would be able to continue after Brexit.
The key phrase in the final version of the short document, which had the backing of both the British and Irish governments, was that there would be "regulatory alignment" between the two sides of the border. What that meant, in plain English, was that EU level rules and standards would continue to apply in Northern Ireland after Brexit, the same as they will in the South. In effect the North would be remaining in the Customs Union and the Single Market. And for that reason, a hard border would not be necessary.
Everyone realised this was going to be a bitter pill for the unionists to swallow, since it meant a significant divergence between the North and the rest of the UK. The North does four times as much trade with mainland UK than it does with the Republic and this arrangement would make that much more difficult and expensive. And of course it would also be a significant shift in the direction of a united Ireland, since politics usually follows economics.
Despite this awkward reality the assumption was that somehow the British Prime Minister Theresa May had got the unionists to agree. The Irish side, including the Taoiseach, were euphoric at the remarkable breakthrough.
Sadly, the elation lasted only a few hours. The DUP leader Arlene Foster quickly burst the bubble, saying she would not accept anything that would separate Northern Ireland economically or politically from the rest of the UK. At lunch-time on Monday she relayed this in a phone call to the British Prime Minister in Brussels, forcing Mrs May to cancel the agreement that had just been finalised by her officials. It was beyond embarrassing, showing that she is not only weak, but incompetent as well.
In retrospect it is clear this was never going to be so easy. But it must have been tempting for the British because it would have meant that at next week's EU summit meeting Ireland would have allowed the Brexit talks to move on to the next stage involving future trade between the EU and the UK.
So the bitter pill had to be swallowed by Mrs May, not the DUP. What was probably a blunt ultimatum from Arlene Foster could not be ignored by Mrs May since it is the votes of the DUP that are keeping her government in power. It's a right mess and it's hard to see a way out.
The status of the Irish border after Brexit is a conundrum that was always going to be difficult to solve, which is why it is the last part of a three-sided puzzle waiting for a resolution. The EU had identified three areas that had to be sorted out before trade talks with the UK could begin -- the size of the UK divorce bill, rights for EU citizens living in the UK and UK citizens living in the EU, and the future of the Irish border.
After a lot of foot-dragging by the British and rows about money, the first two of these seem to be on the way to agreement. There has been "sufficient progress", which is what the EU says it wants before it will start trade talks.
On the Irish Border, however, there was very little progress until Monday morning's surprise announcement. The fact that it all went pear shaped by Monday afternoon now seems almost inevitable. It is by far the most difficult of the three preconditions to solve.
The British had paid very little attention to the issue of the Irish border over the past year, perhaps hoping that it could be swept under the carpet when the much bigger issue of trade talks got underway. The extent of this mistake became clear in recent weeks when the rest of the EU countries backed Ireland's position that there could be no return to a hard border on this island.
The President of the EU Council Donald Tusk made this explicit last week when he visited Dublin and shocked the British by declaring that unless Ireland was happy with the border proposals the talks on Brexit would not move on to discuss trade at next week's summit. So what may have seemed just a minor stumbling block to the British a year ago had turned into a make or break issue for them. And that may have led them to rush Monday's agreement.
There were attempts by the British to fudge the issue over the past year, with talk about a "frictionless" border with no checkpoints, the use of cameras and new technology, exemptions for small traders and so on. The British said repeatedly that they did not want to see the return of a hard border in Ireland. The Irish government went further, insisting that even a soft border with cameras etc would not be acceptable to us.
The reality, however, was that some kind of border was always going to be unavoidable if Britain leaves not just the EU as a political entity but also the EU's Single Market and Customs Union. And that is what the British are determined to do because after Brexit they want to be free to make their own trade deals and customs arrangements with the rest of the world.
Last week, for example, a prominent Conservative Brexiteer was looking forward to all the cheap food Britain will be able to import from the rest of the world once it is outside the EU. Apart from sending shivers down the spines of Irish farmers North and South, this is just one illustration why a hard border would be essential, whether it is on land or in the Irish Sea.
After Brexit, UK importers will be able to bring in shipments of cheap South American beef, for example. If there is no border and they are unscrupulous, they can send it across to Northern Ireland, re-label it as Irish, truck it down to Dublin port (which brings it inside the EU) and export it to France or Germany. Not only will they avoid the stringent EU regulations on hormone and drug use in cattle, they will make a fortune.
Beef is just one example. The same applies across the food sector, where the EU has higher standards and a complex common tariff structure. If there is no border after Britain has left, Ireland could become an open back door into the EU for product from around the world, coming in via the UK.
Nor is it just the agriculture sector that could be a problem. The same applies to pharmaceuticals, electrical goods, clothing and a host of other products that are cheaper on world markets. The problem is that standards and regulations in the global market are lower than those developed inside the EU over recent decades.
In this scenario if there is no hard border between North and South there would have to be a border at Northern ports (the so-called Irish Sea border) to check whether incoming goods from the UK met EU standards. The DUP vehemently opposed any such idea on Monday, insisting that they will be leaving the EU on the same terms as the rest of the UK.
Irish and EU politicians have been saying repeatedly in recent months that it is the responsibility of the British to come up with a solution to the Irish border issue since it was the British who created the problem by deciding to leave the EU. This narrative - Britain must not impose a hard border in Ireland - has been the dominant one here now for weeks.
Listening to it you might think that the British actually wanted a hard border between North and South, despite the fact that they have said repeatedly they want an invisible, soft border.
The real truth is that the UK does not care much what kind of border there is here after Brexit. Britain has much wider concerns than Ireland. It's really the EU that will want a border in Ireland after Brexit if Britain has left the Single Market and Customs Union.
The preferred Irish position has always been that we wanted the UK to stay in the Customs Union and Single Market after Brexit, which would mean no problems for us. Failing that, we wanted Northern Ireland to stay in. And if that was not possible, we wanted a special arrangement for the North which would prevent any divergence between the standards and regulations that will apply in the North after Brexit and those that exist in the EU.
For a few hours on Monday it looked like we had got the last of the three. But looking at the expressions on DUP faces that morning we should have known it was too early to be opening the champagne.
Where we go from here is uncertain. There may be attempts to fudge the wording of the agreement to convince the unionists that "regulatory alignment" does not mean what it obviously means, which is that the North would remain part of the EU Customs Union and Single Market in all but name. Or Mrs May may try to convince the unionists that "regulatory alignment" will apply to all the UK to facilitate free trade with the EU, which would set off a revolt by the hard Brexiteers in her own party.
All of this increases the likelihood of the UK crashing out of the Brexit talks and leaving the EU without any agreement. And the irony is that in that situation the country which would suffer most as a result would be Ireland.
"Theresa May wants to keep the border open in Ireland, while at the same time taking the UK out of the EU with a so-called hard #Brexit. Those two things ultimately contradict," says @jonworth in a DW interview: pic.twitter.com/Fr43pfULGw— dwnews (@dwnews) December 5, 2017