Early internal combustion engine-powered locomotives and railcars used kerosene and gasoline as their fuel. Soon after Dr. Rudolf Diesel patented his first compression ignition engine in 1898, it was considered for railway propulsion. Progress was slow, however, as several problems had to be overcome.
Power transmission was a primary concern. As opposed to steam and electric engines, internal combustion engines work efficiently only within a limited range of turning frequencies. In light vehicles, this could be overcome by a clutch. In heavy railway vehicles, mechanical transmission never worked well or wore out too soon. Experience with early gasoline powered locomotives and railcars was valuable for the development of diesel traction. One step towards diesel–electric transmission was the petrol-electric vehicle, such as the Acsev Weitzer railmotor, which could operate from batteries and electric overhead wires too. (1903 ff.) 
Steady improvements in diesel design (many developed by Sulzer Ltd. of Switzerland, with whom Dr. Diesel was associated for a time) gradually reduced its physical size and improved its power-to-weight ratio to a point where one could be mounted in a locomotive. Once the concept of diesel–electric drive was accepted, the pace of development quickened, and by 1925 a small number of diesel locomotives of 600 hp (450 kW) were in service in the United States. In 1930, Armstrong Whitworth of the United Kingdom delivered two 1,200 hp (890 kW) locomotives using engines of Sulzer design to Buenos Aires Great Southern Railway of Argentina.
By the mid-1950s, with economic recovery from the Second World War, production of diesel locomotives had begun in many countries and the diesel locomotive was on its way to becoming the dominant type of locomotive. It offered greater flexibility and performance than the steam locomotive, as well as substantially lower operating and maintenance costs, other than where electric traction was in use due to policy decisions. Although the diesel–hydraulic locomotive was widely used between the 1950s and 1970s, since then almost all diesel locomotives today are diesel–electric.
The Soviet diesel locomotive TEP80-0002 lays claim to the world speed record for a diesel railed vehicle, having reached 271 km/h (168 mph) on 5 October 1993. TE10 is the most produced diesel locomotive series, totalling no less than 8500 locomotives (19 183 segment units).
The earliest recorded example of the use of an internal combustion engine in a railway locomotive is the prototype designed by William Dent Priestman, which was examined by Sir William Thomson in 1888 who described it as a " mounted upon a truck which is worked on a temporary line of rails to show the adaptation of a petroleum engine for locomotive purposes.". In 1894, a 20 hp (15 kW) two axle machine built by Priestman Brothers was used on the Hull Docks. In 1896 an oil-engined railway locomotive was built for the Royal Arsenal, Woolwich, England, in 1896, using an engine designed by Herbert Akroyd Stuart. It was not, strictly, a diesel because it used a hot bulb engine (also known as a semi-diesel) but it was the precursor of the diesel.
Following the expiration of Dr. Rudolf Diesel's patent in 1912, his engine design was successfully applied to marine propulsion and stationary applications. However, the massiveness and poor power-to-weight ratio of these early engines made them unsuitable for propelling land-based vehicles. Therefore, the engine's potential as a railroad prime mover was not initially recognized. This changed as development reduced the size and weight of the engine.