The Madrid authorities had told Barcelona on Wednesday that the Estelada independence flags could not be flown at the Vicente Calderon stadium, the home of Atletico Madrid because they contravened a 2007 law.
That legislation allowed for a ban on flags and symbols that are deemed to “incite violence” or “show contempt for participants in a sporting event”.
But the judge on Friday ruled that “in no case had it been proven” that the exhibition of the flags could “incite violence, racism, xenophobia or any other form of discrimination that is an affront to human dignity”.
Barcelona said they welcomed the judicial decision to allow the display of Estelada flags.
“The club celebrates that the judge's decision will allow the free expression of legal symbols and banners by its members and supporters,” the Spanish champions said in a statement.
The club has long been an outlet for Catalan who favour secession in the wealthy northeastern region to express their beliefs.
The controversy over the flag ban dominated headlines in Spain just five weeks before a repeat general election in which the ruling conservative Popular Party is once again presenting itself as the best guarantor of national unity.
An influential group of pro-independence campaigners, the Catalan National Assembly, had planned to hand out 10,000 Scottish “Saltire” flags to Barcelona supporters at the final in protest against the ban on the Catalan flag.
But in the wake of the judge's decision to overturn the ban, it called the plan and called on Barcelona supporters to “fill the stands” the Catalan pro-independence flag.
“This is the best way to celebrate victory for freedom of expression, to peacefully demonstrate that the Estelada is a symbol that identifies us, and to answer those who would try to limit our freedom,” it said in a statement.
The head of Catalonia's pro-independence government, Carles Puigdemont, and the mayor of Barcelona, Ada Colau, had both said they would boycoTt the King's Cup final because of the flag ban but after the judge's decision was announced they both said they would now attend.
“The courts have blocked a completely undemocratic decision by the Spanish government,” Puigdemont told a news conference in Barcelona called to announce he would attend the match.