A petrol engine (known as a gasoline engine in American English) is an internal combustion engine with spark-ignition, designed to run on petrol (gasoline) and similar volatile fuels. The first practical petrol engine was built in 1876 in Germany by Nikolaus August Otto, although there had been earlier attempts by Étienne Lenoir, Siegfried Marcus, Julius Hock and George Brayton. The first petrol combustion engine (one cylinder, 121.6 cm3 displacement) was prototyped in 1882 in Italy by Enrico Bernardi. In most petrol engines, the fuel and air are usually pre-mixed before compression (although some modern petrol engines now use cylinder-direct petrol injection). The pre-mixing was formerly done in a carburetor, but now it is done by electronically controlled fuel injection, except in small engines where the cost/complication of electronics does not justify the added engine efficiency. The process differs from a diesel engine in the method of mixing the fuel and air, and in using spark plugs to initiate the combustion process. In a diesel engine, only air is compressed (and therefore heated), and the fuel is injected into very hot air at the end of the compression stroke, and self-ignites.
With both air and fuel in a closed cylinder, compressing the mixture too much poses the danger of auto-ignition — or behaving like a diesel engine. Because of the difference in burn rates between the two different fuels, petrol engines are mechanically designed with different timing than diesels, so to auto-ignite a petrol engine causes the expansion of gas inside the cylinder to reach its greatest point before the cylinder has reached the "top dead center" (T.D.C) position. Spark plugs are typically set statically or at idle at a minimum of 10 degrees or so of crankshaft rotation before the piston reaches T.D.C, but at much higher values at higher engine speeds to allow time for the fuel-air charge to substantially complete combustion before too much expansion has occurred - gas expansion occurring with the piston moving down in the power stroke. Higher octane petrol burns slower, therefore it has a lower propensity to auto-ignite and its rate of expansion is lower. Thus, engines designed to run high-octane fuel exclusively can achieve higher compression ratios.