The EU Council signed the Withdrawal Agreement and approved the Political Declaration on Sunday despite earlier threats by Spanish prime minister Pedro Sánchez that he would not even attend the meeting unless his concerns about the Gibraltar aspect were resolved.
The situation was finally sorted out when the UK provided additional declarations regarding the interpretation of Article 184 in the Withdrawal Agreement. They followed these up immediately after the signing with letters from Ambassador Tim Barrow to the Secretaries General of the EU Council and Commission, stressing how these additional declarations are meant to be interpreted and reminding them that the sovereignty of Gibraltar was non-negotiable.
In the letters the ambassador referred to the double-lock commitment, which is enshrined in the Gibraltar Constitution, under which the UK government will hold no discussions or take any decisions over sovereignty without the approval of the Gibraltar government.
With regard to the territorial scope of the Withdrawal Agreement, he stressed that: "the Government of the United Kingdom further restates that it will negotiate the future agreements implementing the Joint Political Declaration on behalf of all territories for whose external relations the United Kingdom is responsible, including Gibraltar". He also asked that a copy of the letters be sent to the leaders of all EU27 countries.
Not unexpectedly, however, arguments have been raging all week in the UK and Spain about what all this actually means.
Gibraltar's chief minister Fabian Picardo insists that it is the text of the Withdrawal Agreement, which was not changed, which is all that matters and that the additional declarations by the UK are not legally binding in any way.
In Spain, while Pedro Sánchez and foreign minister Josep Borrell claimed to have achieved a historic victory in the 300-year-old 'battle' to regain Gibraltar, opposition parties were saying the same thing as Gibraltar and the UK: Spain had gained absolutely nothing.
The potential problem, of course, lies in the fact that Spain has effectively been given the final say over any deals between the UK and the EU after Britain has left, if they affect Gibraltar. This was Clause 24 in the EU negotiating guidelines, which Sánchez was keen to have stipulated in the Withdrawal Agreement.
Picardo, however, points out that unanimous agreement will be needed anyway at that stage, so Spain always had a veto anyway, just like all other EU countries
If Brexit has to happen, Gibraltar wants the UK to back the Withdrawal Agreement for which Theresa May is now trying to drum up support, because a 'no-deal' Brexit would be "very bad" for Gibraltar. Whether that will happen, however, in the face of the fierce opposition to the deal in the UK so far, is anybody's guess at present.