Fontanelli was born in Modena on 8 November 1775 to a minor Italian aristocratic family, son of Marquis Alfonso and Paolina Cervi.
In 1798 his command returned to central Italy and joined Giuseppe Lechi for a joint march against Rome, however the Pope resigned before the invasion so the Legion remained in garrison at Pesaro.
After the renewed outbreak of hostilities Fontanelli marched towards Ferrara and Verona under Joseph Hélie Désiré Perruquet de Montrichard, serving at the action at Finale and retreating to Bologna, then to Pesaro, where, together with Domenico Pino, he refused to participate in General Lahoz's decision to capitulate.
Following the eventual surrender of Ancona at the end of 1799 Fontanelli was repatriated to France, where in 1800 he was reassigned to command a light infantry battalion of the Legione Italica.
On 1 August 1805 Fontanelli was appointed commander of the Corps of Gardes Velites in the Italian Royal Guard under Pino, holding this post until 1811.
In autumn 1813 he was given command of the 15th Division composed of four regiments and a divisional battery (brigades of Sant'Andrea and Moroni) of Italians in IV Corps under Henri Gatien Bertrand, replacing Luigi Gaspare Peyri, and saw action at the battles of Grossbeeren on 23 August, Dennewitz 6 September, Wartenburg on 3 October and Leipzig on 16–19 October.
After Leipzig, Fontanelli's division successfully held Lindenau, allowing the remains of Napoleon's La Grande Armée to reach France.