Steam locomotives were first developed in Great Britain during the early 19th century and used for railway transport until the middle of the 20th century. The first steam locomotive, made by Richard Trevithick, first operated on 21 February 1804, three years after the road locomotive he made in 1801. The first commercially successful steam locomotive was created in 1812–13 by John Blenkinsop. Built by George Stephenson and his son Robert's company Robert Stephenson and Company, the Locomotion No. 1 is the first steam locomotive to carry passengers on a public rail line, the Stockton and Darlington Railway in 1825. George also built the first public inter-city railway line in the world to use locomotives, the Liverpool and Manchester Railway, which opened in 1830. Stephenson established his company as the pre-eminent builder of steam locomotives for railways in the United Kingdom, the United States, and much of Europe.
In the 20th century, Chief Mechanical Engineer of the London and North Eastern Railway (LNER) Nigel Gresley designed some of the most famous locomotives, including the Flying Scotsman, the first steam locomotive officially recorded over 100 mph in passenger service, and a LNER Class A4, 4468 Mallard, which still holds the record for being the fastest steam locomotive in the world (126 mph).
From the early 1900s steam locomotives were gradually superseded by electric and diesel locomotives, with railways fully converting to electric and diesel power beginning in the late 1930s. The majority of steam locomotives were retired from regular service by the 1980s, though several continue to run on tourist and heritage lines.
The earliest railways employed horses to draw carts along rail tracks. In 1784, William Murdoch, a Scottish inventor, built a small-scale prototype of a steam road locomotive in Birmingham. A full-scale rail steam locomotive was proposed by William Reynolds around 1787. An early working model of a steam rail locomotive was designed and constructed by steamboat pioneer John Fitch in the US during 1794. His steam locomotive used interior bladed wheels guided by rails or tracks. The model still exists at the Ohio Historical Society Museum in Columbus. The authenticity and date of this locomotive is disputed by some experts and a workable steam train would have to await the invention of the high-pressure steam engine by Richard Trevithick, who pioneered the use of steam locomotives.
The first full-scale working railway steam locomotive, was the 3 ft (914 mm) gauge Coalbrookdale Locomotive, built by Trevithick in 1802. It was constructed for the Coalbrookdale ironworks in Shropshire in the United Kingdom though no record of it working there has survived. On 21 February 1804, the first recorded steam-hauled railway journey took place as another of Trevithick's locomotives hauled a train along the 4 ft 4 in (1,321 mm) tramway from the Pen-y-darren ironworks, near Merthyr Tydfil, to Abercynon in South Wales. Accompanied by Andrew Vivian, it ran with mixed success. The design incorporated a number of important innovations that included using high-pressure steam which reduced the weight of the engine and increased its efficiency.