The Milan court judge's decision overturned a 2012 ruling which ordered the seizure of 89 million euros (USD 213 million) and sentenced each bank to pay a 1.0 million euro 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 case revolves around a 1.7-billion-euro bond issue by Milan on which the banks sold derivatives.
More From This Section
The city had estimated its potential losses at about 300 million euros, 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.
"From a legal point of view, that sounds just. But politically, it can only be seen as a defeat," it said.