Spanish Prime Minister Pedro Sanchez said on Saturday that his government had reached an agreement over the future of Gibraltar.
This means Sunday's meeting in Brussels in which European Union (EU) leaders are expected to give their support to the Brexit agreement that would see the UK leave the EU on March 29, 2019, will go ahead as planned.
Spain had threatened to veto the Brexit agreement over what it considered to be a lack of assurances of its future relationship with Gibraltar, the British Overseas Territory situated on the southwest tip of the Spanish mainland.
However, following a reported phone conversation with European Council President Donald Tusk, Sanchez confirmed he would both attend the meeting and support the Brexit deal.
"We have reached an agreement and we will vote in favor of the Brexit," said Sanchez in a declaration made from his official residence at the Palacio de la Moncloa.
"Spain has achieved a historic agreement which would definitively resolve the future of Gibraltar with the United Kingdom in the coming years," said the prime minister.
"Once the UK retires (from the EU), Gibraltar's relationship with the EU will be though Spain," said Sanchez, adding that this decision guaranteed the "national interest, joint prosperity and Spain's key role in the future relationship."
Gibraltar was ceded to the UK in the 1713 Treaty of Utrecht which ended the War of Spanish Succession and has belonged to the UK ever since, much to Spain's frustration and restoring the 'Rock' to Spanish sovereignty is a matter of national pride to many Spaniards.
Nevertheless, 98 percent of the population of Gibraltar voted in 2002 against shared sovereignty between the UK and Spain, while 96 of Gibraltarians voted against the Brexit in the June 2016 referendum in which the UK voted to leave the EU by a narrow margin of 51.89 percent to 48.11 percent.