The International Criminal Court (ICC) has upheld the acquittal of Ivory Coast's ex-President Laurent Gbagbo on charges of crimes against humanity.
It paves the way for his return to Ivory Coast, where he remains an influential figure.
He had been charged in connection with violence following a disputed election in 2010 that left 3,000 people dead.
The first former head of state to go on trial at the ICC, he had denied all the allegations over the bloodshed.
This case was seen as a test of the institution's ability to handle high-profile figures, the BBC's Anna Holligan reports from The Hague.
What's been the reaction to the ruling?
Mr Gbagbo, 75, gave the thumbs up at the war crimes court in The Hague after the ruling, the AFP news agency reports.
His supporters gathered on the grass outside the court were jubilant.
In Ivory Coast there was dancing and singing in a pro-Gbagbo suburb of the main city of Abidjan.
"We say that the whole of Africa has just been liberated today.... That is why we have gone crazy. This day will remain engraved in our memories," supporter Jean Gossé told AFP.
The former president was in court alongside ally and former youth leader Charles Blé Goudé, who was accused of leading a militia backing him.
They were both acquitted in 2019, but the prosecution had appealed what was seen as the shock decision to clear them.
It argued that there were procedural errors in how the original verdict was delivered and insisted that thousands of documents and 96 witnesses presented during the trial had proved their guilt beyond reasonable doubt.
But presiding Judge Chile Eboe-Osuji said: "The appeals chamber, by majority, has found no error that could have materially affected the decision of the trial chamber.
"The appeals chamber hereby revokes all remaining conditions on the release of Mr Gbagbo and Mr Blé Goudé as a result of this judgement."
Mr Gbagbo has been living in the Belgian capital Brussels since his release from detention two years ago.
Back home in November 2019, he was sentenced in absentia for the "looting" of the Central Bank of West African States (Bceao) in the aftermath of the disputed poll - and in theory he could be jailed on his return and it meant he was barred from being a candidate in last year's election.
His successor and erstwhile rival, President Alassane Ouattara, has invited him to return to Ivory Coast, which is still striving for political stability.
Issiaka Diaby, the president of an association for civil war victims, told the Reuters news agency: "We are against this decision of the ICC because the victims were forgotten."
What were the accusations against him?
The violence in Ivory Coast, the world's biggest cocoa producer, came after Mr Gbagbo refused to accept that he had lost a disputed election run-off to Mr Ouattara in 2010.
The five months of violence that followed were described as some of the most brutal clashes the country had ever seen.
During the political stand-off there were bloody clashes and targeted killings in Abidjan in the south, and several hundred were massacred in the western town of Duékoué.
Prosecutors said Mr Gbagbo clung to power "by all means" and charged him with four counts of crimes against humanity, murder, rape and other forms of sexual violence, persecution and "other inhuman acts".
The former president, who was captured in April 2011 hiding in a presidential palace bunker, said the charges were politically motivated.
What does this mean for the ICC?
Whenever a case collapses at the ICC, it damages the perception of the court as a credible tool of international justice, our reporter says.
The appeals judges agreed that the evidence in this case was extremely weak, raising questions about how this trial went as far as it did, she says.
It is not the first case that has collapsed at the ICC.
The court's outgoing prosecutor Fatou Bensouda lost an appeal in 2018 against the acquittal of Jean-Pierre Bemba, former vice-president of the Democratic Republic of Congo, who had been charged with war crimes and crimes against humanity.
Kenyan President Uhuru Kenyatta also saw charges of crimes against humanity over post-election violence dropped by Ms Bensouda in 2014.
The prosecution accused the government of failing to hand over vital evidence and said efforts had also been hampered by an unprecedented effort to intimidate and interfere with witnesses.
Ms Bensouda said Wednesday's judgement would be analysed to "fully appreciate its rationale and import for our work", and added that the investigations into alleged war crimes in Ivory Coast would continue.