The King of Spain has expressed his confidence that his country and Britain will overcome their “differences” over Gibraltar and find a solution “acceptable to all involved”.

King Felipe raised the thorny issue as he addressed MPs and peers at the Royal Gallery in the Houses of Parliament, outside which the flag of Gibraltar was on display in Parliament Square.

The flag’s presence was welcomed earlier at Prime Minister’s Questions in the House of Commons by Conservative MP Andrew Rosindell, who urged Prime Minister Theresa May to remind the King that Gibraltar is British, despite long-standing Spanish claims on the territory.

Mr Rosindell looked on as King Felipe said in the traditional address to both Houses of Parliament that Britain and Spain have a long-shared history and have “frequently stood shoulder to shoulder” as friends, partners and allies, in the best interests of both nations.

The monarch went on: “It is just as true, however, that during our rich and fruitful history there have also been estrangements, rivalries and disputes, but the work and determination of our governments, authorities and citizens have relegated such events to the past.

“I am certain that this resolve to overcome our differences will be even greater in the case of Gibraltar and 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.”

Flags of the overseas territories and dependencies are regularly raised outside Parliament for state occasions such as the King’s visit, and Gibraltar’s flag is placed in the middle because they are in alphabetical order.

Flags of Commonwealth nations were displayed at Horse Guards Parade.