"Our two governments will work out arrangements acceptable to all involved," he said, referring to Gibraltar.
King Felipe said Britain was the second biggest investor in Spain and was an important export market for British companies.
The Chief Minister of Gibraltar, Fabian Picardo, said he was disappointed the King's speech referred to two governments and not three, as the Gibraltar government should have a say on its future.
"Democratic Spain must respect the democratic wishes of the people of Gibraltar. The people of Gibraltar will never give up one iota of their British nationality," said Mr. Picardo.
Juan Carlos, who had been restored to the throne in 1976 after the death of the Spanish dictator Francisco Franco, appealed for a solution to the dispute on that occasion.
But he abdicated from the Spanish throne in 2014 without having seen any solution to the dispute.
Professor Duncan Wheeler, Chair of Spanish Studies at Leeds University, said the King's tone was far less "aggressive" than it might have been, and that was because he was on a diplomatic visit.
He said Brexit had forced Gibraltar's future back onto the agenda, but he said most Gibraltarians would "violently object" to a leaseback proposal, even if it meant the Rock does not return to Spain's possession for 50 years.
"Felipe Gonzalez, the prime minister of Spain in the 1980s always said that Gibraltar was something that the British people think of from time to time but it was a constant pain in the feet of most Spaniards, something that pains them," Professor Wheeler told Sputnik.
Britain has occupied the Rock of Gibraltar, a tiny but strategically important territory at the western end of the Mediterranean, since 1704.
In 1967, the overwhelming majority of its residents voted to remain British, and London's stance has always been that it will not hand back the Rock without the agreement of the 30,000 Gibraltarians.
In June, Gibraltar's Deputy Chief Minister Joseph John Garcia told Sputnik it was crucial that a "fluid" border with Spain was maintained.
Mr. Garcia said 12,000 Spanish residents crossed the border daily to work in Gibraltar, the majority of them Spanish nationals, but some of them citizens of other EU countries.
The issue of Gibraltar and its border will be discussed in the Brexit negotiations.
Earlier this year, the EU's chief Brexit negotiator, Michel Barnier, confirmed Gibraltar would have to leave the EU at the same time as Britain.
King Felipe has been hoping the pending Brexit could weaken Britain's negotiating stance and make Theresa May more amenable to a deal.
In September 2016, he told the UN General Assembly in New York they should help organize a negotiated handover to Spain.
"I invite the UK, on this first occasion at the UN after Brexit, to end the colonial anachronism of Gibraltar with an agreed solution between both countries to restore the territorial integrity of Spain," he said.
One of the ideas thought to have been floated by the Spanish government is a leaseback scheme.
That would involve Britain giving the Rock back to Spain, but then being granted a lease of perhaps 40 or 50 years, which would give Gibraltarians time to prepare for becoming Spanish citizens.
In 1997, Britain's lease on Hong Kong expired and the territory was handed back to China with little fuss.
Earlier this year, the President of the European Council, Donald Tusk, said in order to preserve control over the enclave after Brexit, Britain would have to make an agreement with Spain.
King Felipe, accompanied by Queen Letizia, is due to attend a formal state banquet at Buckingham Palace on Wednesday evening as the guest of Queen Elizabeth II.
Talk around the table might focus on the difficulties each monarch faces in keeping their kingdoms together.
While the Scots have delayed a second binding referendum on independence until after Brexit, the equally rebellious Catalans are planning a non-binding referendum later this year after the government in Madrid refused permission for a binding referendum in Catalonia.
Earlier King Felipe and Queen Letizia were guests at a special welcome ceremony at Horse Guards Parade in London.
The Speaker of the House of Commons, John Bercow, said nowhere in western Europe had changed more in the last half century than Spain, which has been transformed from a fascist dictatorship to a modern democracy.
During a private parliamentary reception the royal couple were given a rare viewing of the Marriage Act of Prince Philip of Spain and Britain's Queen Mary, which was passed in 1554.
The Act is now kept in the Parliamentary Archives.