From humble beginnings to the engines we know today
First a trick question: which came first - the steam engine or the internal combustion (IC) engine? Don't worry if you thought 'steam' because it's the most common answer. The reality is obviously not quite so straightforward or I wouldn't be using up your bandwidth to explain it to you.
The first use of steam to propel something was Hero's 1st century (60AD) Aeophile Steam Turbine but it was more of a toy than an actual engine. Essentially a sphere full of water with a couple of nozzles in it, users would light a fire under it and as the water boiled, steam came out of the nozzles and made it spin. It was fun to watch, and today's health-and-safety execs would have marvelled at the dangerousness of it, but at its root, it was a toy and nothing more.
Huygen's engine
So internal combustion (IC) engines vs. steam - dates please. Well work started on IC engines around the turn of the 16th century, finishing late in the 17th century which was when steam power was starting to show a lot of promise. So much so in fact that IC was just abandoned. Abandoned I tell you! The fools. Well, in fairness, once you see how they worked, it's easy to understand why. At the time, the only half-decent fuel was gunpowder and it wasn't so much the explosion that caused the piston motion as the resulting vacuum from it. The idea was simple. Stuff a piston in the top of a tube, explode gunpowder at the bottom of it to suck up all the oxygen, and the resulting vacuum would cause a pressure imbalance on the piston so that atmospheric pressure would suck it down into the cylinder. Hence these engines were called atmospheric engines. The first attempt at making one of these was in 1673 by Christiaan Huygens. Nice idea but it only worked once and then you needed to refill the cylinder with gunpowder. So it had a single non-repeating cycle and the materials of the day weren't really up to the job of withstanding that sort of strain.
Newcomen Steam Engine
So as this mess was going on with gunpowder, Watt's steam engine and the Newcomen Steam engine were operating on the same principle but using steam instead. As the steam condensed to water, it contracted, creating the vacuum and once again, atmospheric pressure was used to push a piston into a cylinder. The advantage with using steam was that it could be created outside the cylinder and injected when necessary making this a repeatable process. So rather than the one-shot deal of Huygen's engine, these ones could run as long as there was a fresh supply of steam. For 150 years or more, this is how all engines were until piped gas supplies started to become commonplace.