in 1356, after having offended the emperor, he pushed back a first attack upon milan by the imperial vicar markward von randeck, imprisoning him. in 1360 he was declared heretic by innocent vi at avignon and condemned by emperor charles iv. the ensuing conflict ended with a dismaying defeat at san ruffillo against the imperial troops under galeotto i malatesta (29 july 1361). in 1362, after the death of his sister's husband, ugolino gonzaga, caused him to attack also mantua. warring on several different fronts, in december of that year he sued for peace with the new pope, urban v, through the mediation of king john ii of france. however, because barnabò neglected to return the papal city of bologna and to present himself at avignon, on 4 march 1363 he was excommunicated once more, together with his children, one of whom, ambrogio, was captured by the papal commander gil de albornoz. with the peace signed on 13 march 1364, visconti left the occupied papal lands, in exchange for the raising of the ban upon a payment of 500,000 florins.