An appeals court has overturned the conviction of the most senior Croatian military officer charged with crimes during the Balkan wars of the 1990s.
The court ordered the immediate release of Ante Gotovina, who was commander in the Split district of the Croatian army.
Last year he was sentenced to 24 years in jail.
The court also ordered the release of Mladen Markac, a Croatian police commander, overturning his 18-year sentence.
Their acquittals were greeted with jubilation in the Croatian capital of Zagreb where they received a raucous welcome from a crowd of 50,000 after being flown home by government jet.
"We are so happy to be with you tonight. This is our joint victory. The war now belongs to history, let us turn to the future. Thank you and good luck," Mr Gotovina told the crowd from a stage in the main square wreathed in red smoke from thousands of flares.
But Serbia reacted with anger, saying the tribunal had forfeited the right to be considered neutral.
"It is now quite clear the tribunal has made a political decision and not a legal ruling. Today's ruling will not contribute to the stabilisation of the situation in the region and will open old wounds," Serbian President Tomislav Nikolic said.
Following their conviction by the Yugoslavia tribunal's trial chamber last year, the two appealed to its appeals court.
This upheld their claim that they had not been part of a joint criminal enterprise with the aim of permanently removing Serbian civilians from the Krajina region of Croatia.
Prosecutors had claimed the shelling of the town of Knin and three other towns was part of a plan designed to drive out ethnic Serbs.
The decision, by a three-two majority in the five-judge appeals chamber, is one of the most significant reversals in the court's 18-year history.
It overturns a verdict that dealt a blow to Croatia's self-image as a victim of atrocities, rather than a perpetrator, during the Balkan wars in the 1990s.
Neither Mr Gotovina nor Mr Markac showed any emotion at the decision.
Their supporters in the court's packed public gallery cheered and clapped as Presiding Judge Theodor Meron ordered both men freed immediately.
The generals are likely to be returned to their jail cells to complete release paperwork before being freed.
They are then expected to quickly return to Croatia.
Mr Gotovina and Mr Markac were sentenced to 24 and 18 years respectively in 2011 for crimes including murder and deportation.
Judges ruled both men were part of a criminal conspiracy led by former Croat President Franjo Tudjman to expel Serbs.
But the appeals judges said prosecutors failed to prove the existence of such a conspiracy, effectively clearing Croatia's entire wartime leadership of war crimes in the operation known as Operation Storm.
While supporters of the generals at home in Croatia cheered and set off fireworks, the acquittals will enrage hardline opponents of the UN court in Serbia who accuse its judges of anti-Serb bias.
The headline in the Blic daily's online edition read: "Scandalous decision: Gotovina and Markac free as if there had been no operation Storm."
Up to 600 Serbs were killed and more than 200,000 were driven from their homes during the operation.
Mr Gotovina's and Mr Markac's convictions were one of the few at the tribunal set up in 1994 to punish perpetrators of atrocities against Serb civilians.
Mr Gotovina, 55, is especially popular among Croatian nationalists.
The charismatic former soldier fought in the French Foreign Legion in the 1980s and spent four years on the run before being captured in the Canary Islands in December 2005.
The verdicts against the two generals had triggered anti-Western sentiments among nationalist Croatians ahead of the country's planned European Union entry in July 2013.
After the convictions last year, thousands of Croatian war veterans massed in Zagreb and ripped EU flags and denounced Croatia's leaders who have made EU membership their goal.
The original convictions were based on a finding that Croat forces deliberately used illegal artillery attacks on four towns to drive Serb civilians from their homes.
But appeals judges overturned that key finding and said that therefore no criminal conspiracy existed.