Barsanti was born in Pietrasanta, Tuscany. Lean and short of stature, he studied in a Catholic scientific-oriented institute near Lucca, in Tuscany, and became a novitiate of the Piarist Fathers or Scolopi, who were known for being open to scientific study, in Florence in 1838.
In 1841 Barsanti began teaching in the Collegio San Michele, situated in Volterra. Here, during a lecture describing the explosion of mixed hydrogen and air, he realised the potential for using the energy of the expansion of combusting gases within a motor.
Subsequently, when teaching in a college level institute in Florence he met Matteucci. Matteucci appreciated the idea for the engine, and the two men worked together on it for the rest of their lives.
On 12 June 1854, they patented their invention in London, as Italian law at that time could not guarantee sufficient international protection on the patent. The construction of the prototype was later completed in the 1860s.
The main advantage of the Barsanti-Matteucci engine was the use of the return force of the piston due to the cooling of the gas. Other approaches based on the pushing force of the explosion, like the one developed by France's Etienne Lenoir, were slower. The Barsanti-Matteucci engine was proven to be much more efficient, and won a silver medal from the institute of science of Lombardy.