Railway sabotage was one of the main tactics used by the resistance to German occupation during World War II. Partisans and rail workers used sabotage to harass and confuse the invaders, misdirect, destroy, and lose their troops and supplies, and to damage railroad infrastructure, denying the occupiers its use.
 The new methods of mobile war heavily relied on military logistics, for fuel, food, ammunition and other supplies. Germany was especially dependent on Deutsche Reichsbahn and captured railways on the Eastern Front of World War II, fuel being scarce for road transport and horses in World War II died at a high rate, as in earlier wars. 
 Gordon L. Rottman noted that "railroad sabotage was one of the most frequent partisan activities in all theaters of the war".  In addition to violent attacks by organized resistance, acts of rail-related sabotage also included actions by railway workers such as causing minor accidents and delays, misdirecting and misrouting trains, and other similar acts.
 In Polish and Russian historiography, the attacks are often called "Battle for the railways" (Polish: Bitwa o szyny) or "War of the Rails". These terms have  been used in the Polish historiography as early as in 1975 and at first was used to describe the operations of Polish and Soviet partisans in 1943. Newer Polish works, however, use it more broadly in the context of all partisans operations in occupied Europe directed against the German-controlled railway infrastructure in the period of 1939–1945.
 Railway sabotage has been described as very successful in Denmark.
 In 1944, before D-Day landings, Britain and the French Resistance coordinated a series of railway sabotage actions known as Plan Vert. French resistance railway sabotage, with a focus on the Résistance-Fer organization, was the subject of the 1946 French documentary The Battle of the Rails.
 A major incident of railway sabotage in Greece took place in November 1942, when the Greek resistance fighters demolished a chain of three viaducts on the Thessaloniki-Athens line. Later they also blew up the Gorgopotamus Viaduct (Operation Harling) and the Asopos Viaduct.
 Among the most notable acts of railway sabotage in Norway was the Thamshavn Line sabotage.
 Occupied Poland became an important transit area connecting Germany to the Soviet Union territories, and rail transport was the main method of transportation of resources for the German war effort. Following the end of organized Polish resistance in October 1939, Germans started to rebuild the damaged infrastructure, and then improve it beyond the pre-war level. Following the German invasion of the Soviet Union, close to 100% of the German supplies to the Eastern Front lines passed through the former Polish territories.  
 The Polish resistance attitude towards railway sabotage was complicated. On one level, it was seen as a viable target of opportunity, disrupting the German war effort. At the same time, the Soviet Union, which had also invaded Poland in 1939, was seen as another enemy of the Polish state, and therefore there were debates within the Polish resistance loyal to the Polish government-in-exile as to what extent efforts aiding Soviet Union were in the best interest of Poland. As a result, the decision was made by the majority of the Polish resistance, affiliated with the government-in-exile and the Polish Underground State, to conduct only limited railway sabotage, while a plan for a wide-scale action aiming to totally disrupt it, codenamed "Akcja Bariera" was drawn up but shelved. The smaller communist-affiliated resistance, however, rejected this and supported extensive attacks at the German supply lines.
 The first acts of railway sabotage on Polish territory occurred during the German invasion in September 1939 by Polish units tasked with carrying out operations behind enemy lines (Polish Diversionary Forces [pl]). Such acts, however, were few, and the organized sabotage stopped after a few months, as the Polish resistance had just begun organizing at that point. Many early acts of sabotage in the first years of occupation were by individuals with little connection with or support from organized resistance, often by Polish railway workers working for the German railways (Reichsbahn and Ostbahn). In addition to causing simple delays, common acts of sabotage at that time included arson and damage to wagon traction or brakes. The first organized partisan attacks on the railways would occur in 1940, at first averaging about once a month; such acts would not become common until the summer of 1942. While most operations of the Polish resistance took place in Poland, several notable acts of railway sabotage involved actions outside former Polish territories, with the Union of Retaliation and Wachlarz conducting bombings and sabotage in Germany (Berlin in 1940 and 1942) and Belarus (Minsk in 1942). Activity of the Polish resistance, including attacks on railway infrastructure, intensified from the autumn of 1942; the numbers of attacks quadrupled or more between 1942 and 1943 (for example, Warsaw had 25 acts of railway attacks in 1942 compared with 138 in 1943). Particularly notable were four large-scale operations of 1942 and 1943. The first three (in October and November 1942 and January 1943) were organized by the Union of Retaliation and Kedyw groups of the Polish Home Army. The fourth was organized in September 1943 by the communist Gwardia Ludowa. Each of those four actions resulted in major disruption and delays to German logistics.
 According to German reports, Polish resistance carried out approximately 600 attacks on railway infrastructure in the years 1942–1943. 
 The resistance activity in Poland intensified further in 1944, as the Eastern Front approached and crossed the Polish borders. This period also marked an increase in activity of communist-affiliated partisans, both Polish and infiltrating units directly under Soviet command. Between January and July 1944, the combined efforts of Polish and Soviet partisans in the Lublin District, which was the scene of most of the sabotage efforts of that period, resulted in about 800 attacks against railway targets. As parts of the Lublin region were occupied by the advancing Soviet forces and the front line stabilized for a few months in the Autumn, further attacks on railway targets occurred in the western Radom District. The last acts of railway sabotage involving Polish resistance took place around 20 January 1945 in the Western Beskids.
 In 1993, Marek Ney-Krwawicz [pl] counted approximately 29,000 acts of railway-related sabotage (including smaller incidents) for the period of 1941-1944 (see table). 
 In 1994, Richard J. Crampton estimated that one eighth of all German transports to the Eastern Front were destroyed or substantially delayed due to Home Army operations. The approximate number of railway sabotage operations carried out by Polish resistance and/or on the Polish territories in the years 1942-1945 was estimated by Krzysztof Komorowski in 2009 at around 2850 operations (including about 7% of failed attempts), noting that the successful attacks targeted 1825 large and 100 small train complements and resulted in numerous incidents of damage or destruction to tracks (380), bridges (150) and stations (210). He also noted that the acts of sabotage intensified, with 1942 having about 100 attacks, 1943, about 600, and the last two years, over 2,000. Komorowski also noted that numerous acts of sabotage were carried out by Polish railway workers in repair depots or at stations, but they are hard to quantify.
 Between 1940 and 1944, the Romanian Communist Party organized isolated attacks on railroads. Their impact on the German war effort, which relied on petroleum from Ploiești, was minimal.
 Soviet partisans carried out a large number of attacks on German railway infrastructure, particularly in 1943. Germans recorded over 400 attacks in March of that year, with a peak of 1100 in July. August 1943 in Belarus saw 21,300 rail attacks; further attacks occurred from September to November that year. According to German documents, in that period the Soviets destroyed 20,505 rails. In 1944 Soviet partisans damaged or destroyed thousands of locomotives and wagons. Soviet reports are considered to be exaggerated, but Alexander A. Hill concluded that "damage done to German communicators was at times significant". As happened in Poland, the partisan activity and the corresponding damage to German rail infrastructure intensified as the war progressed and turned increasingly unfavorable for the Germans.
 In German occupied Serbia and some nearby regions the Yugoslav Army in the Fatherland (commonly known as Chetniks) organized a campaign of sabotage of Axis communication lines mostly along the rivers Morava, Vardar and Danube, to obstruct transport of German war material through Serbia to Thessaloniki and further to Libya during Western Desert campaign. The Chetnik sabotages were organized since 31 April, or according to some sources since July or early August 1942. After initial support to Mihailović's Chetniks tactics used against Axis forces in Serbia, since the closing of Summer 1942, the British started to believe that such actions were not enough. On the other hand, the German command decided that such actions were enough for them to make the decision to annihilate Chetniks.
 In the Independent State of Croatia (NDH), railroads were a frequent target of partisan attacks and an important part of partisan strategy from the very beginning of the war. By July 1942, out of 4000 km of railroad lines, 1700 km were either destroyed or made unsafe for use. Rijeka-Moravice line saw several hundred attacks in 1942 alone, in which 40 railwaymen were killed and more than 100 were injured. 1,800 trains were sabotaged by Partisan actions by early-1942, including trains used to transport supplies of Romanian oil to the Axis powers. Defending the trains was so hazardous that transfer to train detail was used as a form of severe punishment in the NDH armed forces. According to NDH general Slavko Kvaternik, maintaining regular transport incurred "enormous problems, heavy railroad security, [tying down] at least one half of the armed forces, and great destruction and loss of personnel and materiel". German army also had to use significant resources of their own to protect the strategically important Zagreb-Zemun line. Despite extensive countermeasures, which included construction of watchtowers, bunkers and other fortifications, use of armored trains, forced evacuation of entire settlements, as well as hostage taking, the attacks and interruptions continued, significantly impairing the transport and the economy of the Independent State of Croatia.
 In addition to various anti-partisan and pacification actions, Germans employed armored trains to secure their rail transportation networks. Those ranged from large platforms to armored draisines, often used for reconnaissance. Other methods of securing the railway lines included having the trains travel in convoys, attaching security formations to the trains, ranging from police auxiliaries to dedicated anti-insurgency units, construction of fortified posts at vulnerable or key spots, protecting them with fences and patrols, cutting down forests up to several hundred meters along the tracks to deny cover to the partisans, and establishing no-go zones around the tracks, which in extreme cases even led to displacement of entire villages. Overall, however, the German tactics have been described as having only limited results in preventing railway sabotage.