The European flag is to continue flying outside the Scottish Parliament beyond Brexit after MSPs voted to keep it up.
Holyrood's management group had planned to lower the flag at 23:00 on Friday, the moment the UK leaves the EU.
However MSPs voted by 63 to 54 to overturn this decision after the Scottish government forced a debate.
Presiding Officer Ken Macintosh warned ministers not to politicise the issue, saying the flags flown at Holyrood "reflect our relationships in law".
The Conservatives, Labour and the Lib Dems argued that the "non-political" decision of the Parliamentary Corporate Body should be respected, but SNP and Green MSPs united to "direct" the group to keep the flag up.
The Scottish Parliamentary Corporate Body (SPCB) - a management group made up of an MSP from each of Holyrood's parties - had made the decision to remove the flag after Brexit, but to fly it each year on Europe Day.
However this has now been overturned after a brief but heated debate in the chamber, with the group pledging to abide by the result of the vote.
The motion passed by MSPs noted that Scotland and the UK would remain in the Council of Europe, and said the flag should stay up "as a sign of support and solidarity with those EU nationals who have made Scotland their home".
Leading for the government, External Affairs Secretary Fiona Hyslop said MSPs should "stand firm in solidarity with all the EU citizens who live in Scotland" and keep the flag flying "as a practical demonstration of our regret" about Brexit.
She said ministers did not take the prospect of "directing" the parliamentary authorities lightly, and said "it should not happen regularly" - but said "I do not believe their decision reflects the views of parliament as a whole, and nor do I believe that the decision could be non-political".
Green MSP Ross Greer echoed that point, saying there was "no way to make the binary choice between keeping the European flag up and taking it down without that choice being political".
But Tory Liz Smith said it was "vital there is full trust and confidence" in the "impartial" work of the SPCB, warning that members should be "well aware of the dangers" of "undermining" the group.
Labour's Daniel Johnson said the corporate body had been set up to be "beyond party politics" so that "the parliament should not be within the control of the government", and that this principle could be "undermined" by the vote.
And Lib Dem Liam McArthur said Holyrood's flags were "a statement of legal fact, not political desire", adding that "we have a duty as MSPs to protect the neutrality of this institution".