Germany has made public burning of the EU flag or that of another country punishable by up to three years in jail, classing it as a hate crime.
The vote in the Bundestag (parliament) on Thursday makes defiling foreign flags equal to the crime of defiling the German flag.
The same applies for the EU anthem, Beethoven’s Ode to Joy theme.
The move followed Social Democrat (SPD) complaints about protesters’ burning of the Israeli flag in Berlin in 2017.
Justice Minister Christine Lambrecht, a member of the centre-left SPD, said “burning flags publicly has nothing to do with peaceful protests”. She said it stoked up “hatred, anger and aggression”, and hurt many people’s feelings.
The new law also applies to acts of defilement besides burning, such as publicly ripping a flag up. Public display of the Nazi swastika and other Nazi symbols is already banned in Germany.
The far-right Alternative for Germany (AfD) has condemned the new law as “excessive interference in free speech and artistic expression”.
The act of defiling the Union Flag in the UK is not a crime, but France has made desecration of the tricolour punishable by a fine of up to €7,500 (£6,600; $8,000) or six months in jail.
Spain, Italy and Greece also have laws banning desecration of the national flag.