Spanish King Felipe VI called for a deal on the status of Gibraltar that would be "acceptable to all" on Wednesday, raising a thorny dispute on the first day of his state visit to Britain.
"I am confident that through the necessary dialogue and effort our two governments will be able to work... towards arrangements that are acceptable to all involved," Felipe told the British parliament.
Referring to the history of diplomatic relations between Britain and Spain, he said: "I am certain that this resolve to overcome our differences will be even greater in the case of Gibraltar."
With a population of just over 32,000, Gibraltar has been a British overseas territory since 1713 but Spain has long laid claim to the rocky outcrop.
Unlike Britain, Gibraltar voted overwhelmingly to stay in the European Union in last year's referendum, and it depends on an open border with Spain for its workforce and trade.
But Spain wants shared sovereignty and the EU has promised Spain a veto over the extension to Gibraltar of any future trade deal between Britain and the bloc, sparking a storm of outrage in London.
Gibraltar's chief minister Fabian Picardo reacted scathingly, saying: "What the king has said really harks back to a time when the governments in Madrid and London might make decisions over the heads of the people of Gibraltar."
He told Sky News television: "My concern is that the voice of the people of Gibraltar might not be heard in a process that is about the people of Gibraltar."
Brexit 'saddens' Spain
The king's speech was overwhelmingly conciliatory, speaking about shared history between the two countries as well as joint efforts against terrorism after four attacks in Britain this year.
He said Brexit "saddens" Spain but that it fully respected the result of last year's vote.
Felipe spoke about the hundreds of thousands of Spaniards living in Britain and Britons living in Spain, whose future hangs in the balance as Britain negotiates its withdrawal from the EU.
"These citizens have a legitimate expectation of decent and stable living conditions for themselves and for their families," he said, calling for a deal that would provide "sufficient assurance" to them.
There are an estimated 300,000 British citizens living in Spain - the majority of them retirees - and around 116,000 Spaniards living in Britain.
The king spoke at length to express sympathy with the victims of the recent terror attacks in Britain.
A Spaniard was among the eight people killed in an attack by three Islamist sympathisers wielding knives and wearing fake suicide vests in the London Bridge area last month.
Felipe paid tribute to 39-year-old Ignacio Echeverria, a money-laundering expert at HSBC bank, who reportedly struck one of the attackers with his skateboard before being stabbed.
The king said Echeverria had behaved in "an exemplary and heroic manner".
The visit by Felipe and his wife Queen Letizia was delayed twice, once while Spanish politicians formed a new government last year and again last month because Britain held a snap general election.
The Spanish royals were greeted on Wednesday by Queen Elizabeth II - a distant cousin of Felipe - at an elaborate ceremony in central London.
They are due to attend a banquet at Buckingham Palace later on Wednesday and Felipe will meet British Prime Minister Theresa May on Thursday where the subject of Gibraltar could be raised again.
Business will also be on the agenda and top Spanish business leaders will accompany the royals, including from Ferrovial, a Heathrow airport shareholder, Santander bank and telecoms firm Telefonica.