The Milan court judge's decision overturned a 2012 ruling which ordered the seizure of €89 million and sentenced each bank to pay a €1.0 million fine.
Nine bank employees who had been given suspended jail sentences of up to eight months were also acquitted.
Deutsche Bank said in a statement that it "welcomed" the verdict, which showed the bank and its employees "acted properly and in compliance with all laws and regulations", while UBS said it was "pleased that the Milan appeal court overturned all findings of liability/convictions."
The trial began in 2010 after a three-year investigation into the banks, which were accused of hiding the risks in the derivative financial products they sold to the city of Milan while restructuring its debt, promising that the products would save the city money.
The case revolves around a €1.7 billion bond issue by Milan on which the banks sold derivatives.
The city had estimated its potential losses at about €300 million, but the banks insisted from the start that they were innocent.
Multiple local governments have unwittingly signed damaging derivatives deals in the past and the trial - the first of its kind in Italy - has been closely watched for the precedent it would set on taking lenders to court.
"The judges have declared that the incompetence of the political class is not proof of a scam, and that therefore anything signed by both bank and city is fully legitimate," Italy's Sole 24 Ore financial daily said.
"From a legal point of view, that sounds just. But politically, it can only be seen as a defeat," it said.