In two referenda held in 1967 and 2002 the people of Gibraltar voted to remain British.
King Felipe also addressed Brexit during his speech, which was watched by the PM and Labour leader Jeremy Corbyn.
'We are firm friends, and I look forward to seeing our partnership go from strength to strength in the years ahead'.
Normally, royal visits are all waves and smiles, with less-than strenuous conversation with a few hand-picked commoners or the public tasting of a weird local delicacy to disrupt the flow.
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.
Britain says Gibraltar's status is not up for negotiation.
"I really wanted to talk to the King and I did when he came and stood with us".
Prince Harry, in his first involvement in a state visit, will take the royal couple around Westminster Abbey before the Spanish king addresses both parliaments.
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, prompting outrage in London.
Prince Charles, Camilla, Prince William and Prince Harry were also in attendance at the event, which was Harry's first official state banquet appearance in support of his grandmother. As the king said, the UK and Spain enjoy an incredibly strong relationship.
During the summit Mrs May will pay tribute to Spanish banker Ignacio Echeverria, who died trying to save a woman from an attacker in the London Bridge terror attack.
In Thursday's auction in Madrid, however, they went for 201,555 and 242,287 euros, one of them to a car dealership and the other to a private buyer, the finance ministry announced in a statement. Outside, the Spanish queen greeted well-wishers, including a group of schoolchildren. But if there is a vote for secession, nationalists in Scotland and Wales will back calls for the UK to recognise the result.
The Queen gave Felipe a bound album featuring pages from the Royal Library and Royal Archives.
At the Tomb of the Unknown Warrior.
- Arrebatan liderato del Tour de Francia a Froome
- Desaparecen los "Gracias, Presidente" tras socavón en Paso Exprés de Cuernavaca
- Jeisson Vargas vuelve a Universidad Católica
- Kit Harington se convierte en otros personajes de 'Game of Thrones'
- Por las nevadas, cerraron los aeropuertos de Chapelco, Ushuaia y Bariloche
- ¡ATENCIÓN! Rigoberto Urán gana la novena etapa del Tour de Francia
- Niega Rusia haber intervenido en reunión de abogada con Trump Jr
- Un mujer con muerte cerebral dio a luz a gemelas
- Repudian la represión en PepsiCo y la violencia contra la prensa
- Rigoberto Urán triunfa en final de fotografía