Fortification is almost as old as warfare itself, however it was traditionally not possible to defend more than a short defensive line or an isolated strongpoint. The very long fortifications of the ancient world, such as the Great Wall of China or Hadrian's Wall, were exceptions to the general rule and were in any case not designed to prevent entry of enemy troops, but simply to make it difficult for the invader to mount a penetration in strength. The Great Wall of China, for example, was not intended to keep raiders out, merely to prevent them bringing their horses.
Although both the art of fortification and the art of weaponry advanced a great deal in the second half of the second millennium, the advent of the longbow, the muzzle-loading musket, and even of artillery did not substantially change the traditional rule that a fortification required a large body of troops to defend it. Small numbers of troops simply could not maintain a volume of fire sufficient to repel a determined attack.
With the development of improved firearm technology in the mid-19th century, the situation changed rapidly. When the American Civil War opened in 1861, it was fought with much the same weapons and much the same tactics that had been used in the Napoleonic wars and indeed for several centuries. By the time it drew to a bloody close in 1865, it had become a preview of the First World War: complete with trenches, machine guns, field fortifications, and massive casualties.
Two main factors were responsible for the change. First, the new breech-loading firearms—which were curiously ignored by both sides until mid-way through the conflict—made it possible for a small number of troops to maintain a heavy volume of fire. A handful of defenders sheltering in a trench or behind an improvised obstacle could hold off a large body of attackers indefinitely. Second came the machine gun, which multiplied the power of the defender still further and yet did little for an attacker (provided only that the defenders could take cover).
Two less-significant but still major factors played a part. One was the development of barbed wire, which in itself did little harm to anyone but—crucially—could slow the progress of an attacking force, and thus allow emplaced machinegunners and riflemen time to inflict unacceptable losses.
Finally, after the end of the American Civil War, came the invention of modern high-velocity breech-loading artillery. Artillery in one form or another had been a part of warfare since classical times, and from the rise of gunpowder until the development of trench warfare in the 1860s had been a major killing force. With the development of modern artillery by Krupp, however, artillery regained much of its former killing power (as was graphically demonstrated in the Franco-Prussian War of 1870 to 1871).
Trench warfare reached its height in World War I. German and Allied (mostly French and British) forces soon learned that with modern weapons even a shallow scrape in the soil could be defended by a handful of infantry. To attack frontally was to court crippling losses, so an outflanking operation was essential. An extended series of attempted outflankings, and matching extensions to the fortified defensive lines, soon saw the celebrated "race to the sea"—the German and Allied armies dug what was essentially a single pair of trenches from the south coast of Europe to the north.
On the Western Front, the small, improvised trenches of the first few months rapidly grew deeper and more complex, gradually becoming vast areas of interlocking defensive works. (A similar pattern followed in Gallipoli, but on the Eastern Front and in the Middle-East, the areas to be covered were so vast, and the distances from the factories that supplied shells, bullets, concrete and barbed wire so great, that trench warfare in the European style often did not eventuate.)
Ever greater forces of artillery were massed to try to batter the opposing lines into submission. The main effect was to churn the ground up into vast seas of mud: organised tactical movement became almost impossible; any attempt to advance was slowed still further, troops in the open were exposed to fire for a longer time.
Enormous frontal attacks by thousands of infantrymen took place, backed by massive artillery barrages and poison gas. The territorial gains were trivial; the losses so heavy that both sides began to run out of troops to waste. For the Axis, ever-harsher conscription laws and an emphasis on at least a little economy of life was the response. The Allies poured in troops from Canada, Australia, New Zealand, South Africa, the French African colonies, and eventually the United States, always in the hope that, this time, a yet bigger attack with still more unarmoured troops and an even longer artillery barrage to precede it would finally achieve the chimerical goal of a general break-through.
From time to time, at a frightful cost in human life, attackers did indeed break through the opposing line. But in no case was it possible to exploit the break: it was always easier for the defender to bring up reserves and improvise another trench line than it was for the attacker to pass his own reserves through the broken ground and mud and chaos of the battlefield. In any case, attacking generals had no way of knowing that a breakthrough had in fact occurred until a messenger from the front could arrive, usually on foot. Field telephone wires rarely survived a defensive artillery barrage, and by the time new ones could be laid, the opportunity had passed.
The new tactic of trench warfare had come about as a response to the new technologies of rapid fire weapons and mass-produced barbed wire. In consequence it is often thought that the end of trench warfare was itself brought about by new technologies, in particular the tank. Tanks were certainly a significant factor, however until quite late in the war they were available in only small numbers, and were often mis-employed by generals who had (of course) not yet gained experience with them. Soon after the war, analysts on both sides were highly motivated to exaggerate the role of the tank in ending trench warfare. For the Germans, it provided a ready explanation for their loss of the war; for ambitious Allied soldiers keen to see a large and independent tank corps (notably J.F.C. Fuller), stressing the importance of the tank was a way to achieve political goals; and for analysts in general, the tank provided a ready technological explanation where none of the other contemporary changes in military hardware seemed to fit—aircraft, gas, vastly more powerful artillery, and improved communications could not easily be understood to have made the difference.
In fact, the tank was only a partial explanation for the demise of trench warfare. Many Allied victories from 1917 on were achieved without tanks, or with very few of them, and the Germans too made large gains in early 1918 despite having hardly any tanks at all. The key lesson—which German tacticians learned all too well, and taught to their Allied pupils in the Blitzkrieg of 1940—was not technological but tactical. The keys to breaking the stalemate of trench warfare were to achieve tactical surprise, to attack the weakest parts of an enemy's line and bypass his strongpoints, and to abandon the futile attempt to have a grand and detailed plan of operations and control it from afar, instead relying on small, autonomous combined arms groups of well-trained soldiers where the junior leaders on the spot could exercise initiative.
The tank made it more difficult to defend a trench line. Combined arms warfare, where infantry, light artillery, and (if possible) tanks and aircraft operated in close cooperation made trench warfare obsolete.