Beginning in the 1920s, steam locomotives were gradually retired and replaced by diesel and electric locomotives. The timeframe of this process varied by country.

Railfan & Railroad stated in 2022 that "the only places on earth to see steam locomotives in revenue freight service are small switching operations in China, North Korea and Bosnia," but that these were "sporadic at best." Tourist locomotives are still in regular use.

Retirement of steam locomotives by country

North and South America

United States

The first diesel locomotives appeared on the Central Railroad of New Jersey in 1925 and on the New York Central in 1927. Moving forward, diesel locomotives began to appear in mainline service in the United States in the mid-1930s. Compared to steam, diesel power reduced maintenance costs dramatically while increasing locomotive availability. On the Chicago, Rock Island and Pacific Railroad, new units delivered over a year, compared with about for a mainline steam locomotive. World War II delayed dieselisation in the US until the late 1940s; in 1949, the Gulf, Mobile and Ohio Railroad became the first large mainline railroad to convert completely to diesel locomotives, and Life Magazine ran an article on 5 December 1949 titled "The GM&O puts all its steam engines to torch, becomes first major US railroad to dieselize 100%". The manufacture of new steam locomotives for stateside use decreased as dieselization continued. The Lima Locomotive Works was perhaps the last commercial builder of steam locomotives, with the final order completed being for ten “Berkshires” for the New York, Chicago & St. Louis Railroad in 1949. The last steam locomotive manufactured for general service in the United States would follow in 1953: a Norfolk and Western , built in the railroad's Roanoke Shops. 1960 is normally considered the final year of regular Class 1 main line standard gauge steam operation in the United States, with operations on the Grand Trunk Western, Illinois Central, Norfolk and Western, and Duluth Missabe and Iron Range Railroads, as well as Canadian Pacific operations in Maine. The Grand Trunk Western did, however, use some steam power for regular passenger trains until 1961, the last instance of this occurring unannounced on trains 56 and 21 in the Detroit area on 20 September 1961 with 6323, one day before its flue time expired. The last steam-powered standard-gauge regular freight service by a class 1 railroad came little over a year later on the isolated Leadville branch of the Colorado and Southern (Burlington Route) on 11 October 1962 with 2-8-0 641. Narrow-gauge steam was used for freight service by the Denver and Rio Grande Western on the run from Alamosa, Colorado, to Farmington, New Mexico, via Durango until service ceased on 6 December 1968. The Denver and Rio Grande Western would keep its narrow gauge steam power active, however isolated from its main network, until in 1981 when Florida business man Charles Bradshaw bought the Durango and Silverton line from the D&RGW and renamed it the Durango and Silverton Narrow Gauge Railroad with its first season starting in 1982.

Retirement of steam locomotives by country

The Union Pacific Railroad is the only Class I railroad in the US to have never completely dieselised, at least nominally. It has always had at least one operational steam locomotive, Union Pacific 844, on its roster.

Retirement of steam locomotives by country

Some US shortlines continued steam operations into the 1960s and beyond; the Northwestern Steel and Wire mill in Sterling, Illinois continued to operate steam locomotives until December 1980, and the Crab Orchard and Egyptian Railway, which had used steam since its inception in 1973, continued until September 1986. By this time, around 1,800 of the over 160,000 steam locomotives built in the United States between 1830 and 1950 still existed, with a fraction still in operating condition at museums, on tourist railroads, or in use on mainline excursions.

Mexico

On the contiguous North American standard gauge network across Canada, Mexico and the United States, the use of standard gauge main line steam locomotion using s built in 1946 for handling freight between Mexico City and Irapuato lasted until 1968. The Mexican Pacific line, a standard gauge short line in the state of Sinaloa, was reported in August 1987 to still be using steam, with a roster of one , two s and one .

Other countries

In Paraguay, wood-burning steam locomotives operated until 1999.