Trench warfare
In April 1915, chlorine gas was first used by Germany at the Second Battle of Ypres. Exposure to a large dose could kill, and those not killed could suffer permanent lung damage. But the gas was easy to detect by scent and sight. Phosgene, first used in December 1915, was the most lethal killing gas of World War I; it was 18 times more powerful than chlorine and much more difficult to detect.
However, the most effective gas was mustard gas, introduced by Germany in July 1917. Mustard gas was not as fatal as phosgene, but it was hard to detect and lingered on the surface of the battlefield, so could inflict casualties over a long period. Even if not inhaled, it could slowly burn the skin, but quickly burned via the eyes or any wounds, causing blindness and intense suffering. Mustard gas also had the property of being heavier than air, causing it to sink down hills and therefore down into trenches. Casualties from mustard gas were unlikely to be fit to fight again, yet only 2% of mustard gas casualties died. The added burden of long-term care of casualties from mustard gas actually increased its overall effectiveness compared to more immediately lethal gas agents.

Tanks: Tanks were developed by the British and French as a means to attack enemy trenches, by combining heavy firepower (machine guns or light artillery guns), protection from small-arms fire (armour), and battlefield mobility (tracks). The British tanks were designed with a rhomboid shape, to easily surmount barbed wire and other obstacles. They were first deployed in 1916 at the Battle of the Somme in limited numbers, proving unreliable and ineffective at first, as mechanical and logistical issues overshadowed implementing a coherent tank doctrine, with the additional challenge of traversing ground torn apart by years of shell fire. At the First Battle of Cambrai in 1917, improved tanks in larger numbers demonstrated the potential of tank warfare, though German improvised anti-tank tactics, including using direct fire from field artillery, also proved effective.
By 1918, tank capabilities and tactics improved, their numbers increased and, combined with French tanks, finally helped break the stalemate. During the last 100 days of the war, Allied forces harried the Germans back using infantry supported by tanks and by close air support. By the war's end, tanks become a significant element of warfare; the proposed British Plan 1919 would have employed tanks as a primary factor in military strategy. However, the impact of tanks in World War I was less than it could have been, due to their late introduction and the inherent issues that plague implementing revolutionary technology. The introduction of the tanks would mark the beginning of the end of trench warfare.
Between the two world wars many nations developed their own unique tanks and divergent theories of tank tactics, including the UK, France, the Soviet Union, Czechoslovakia, Japan, the US, and Italy. Though German tank development was restricted by the terms of the treaty ending World War I, Germany successfully combined their own tanks (plus Czech tanks from occupied Czechoslovakia) with infiltration tactics to produce blitzkrieg during World War II.

Later use: 

Spanish Civil War: Trenches were often used in both sides particularly the Nationalists whose military ground doctrine emphasized static defence. The Republicans also employed the use of trenches, but also human wave attacks most notably during their defence of Casa de Campo in the Siege of Madrid.

World War II: In the decade leading up to World War II, the French built the Maginot Line, based on their experience with trench warfare in World War I. The Maginot Line was an extensive state-of-the-art defensive system far superior to any previous trench system: a chain of massive constructions of concrete, iron, and steel fortresses, bunkers, retractable turrets, outposts, obstacles, and sunken artillery emplacements, linked by tunnel networks.  It covered the length of the Franco-German border and was 20–25 kilometres (12–16 mi) wide. It was supported by numerous underground barracks, shelters, ammunition dumps and depots, with its own telephone network and narrow gauge railways with armoured locomotives, backed up with heavy rail artillery. French military experts placed high value on the line, saying it would curb German aggression, as any invasion force would be halted long enough for French forces to mobilize and counterattack. Furthermore, French military planning during the inter-war period believed that the line would force the Germans to invade Belgium. This would allow any future conflict to take place off of French soil. By bypassing the Maginot Line and fighting the Belgian Army, it would allow the French military to move its best formations to counter. In the Battle of France, Germany invaded Belgium and the best Anglo-French forces moved to meet them as planned. However, the Germans had only recently changed their plans from what the French had anticipated would happen. Instead of an attack through central Belgium, the main German attack was delivered through the Ardennes forest. Inter-war French planning believed it would take the Germans 9 days to move forces through this area, and that it could be held by small forces. The German forces outpaced expectations and soon crossed into France between the main French forces and the Maginot Line. They then advanced towards the English Channel, and surrounded the Anglo-French armies. Small secondary German attacks concentrated at a few points in the Line had mixed success. The bulk of the Maginot Line was untouched, its garrisons withdrawn, and flanked. Due to the lack of combat, much of it has survived.
The return of mobile warfare in World War II reduced the emphasis of trench warfare, as defenders commonly lacked the time to build up such battlefield defences before they were forced to redeploy, due to the more rapidly-changing strategic situation. But trench systems were still effective, wherever mobility was limited, the front lines were static, or around known critical objectives that could not be bypassed. More quickly improvised defensive fighting positions, using "scrapes" or "foxholes", that can be supplemented by sand bags, local materials, debris, or rubble, remain in common use. These are typically improved and expanded by the defenders, eventually becoming full trench systems, if given enough time and resources.
In the Winter War, the Mannerheim Line was a system of flexible field fortification for the defending Finns. While having very few bunkers and artillery compared to heavy defence lines like the Maginot Line, it allowed defensive platoons to regroup between field fortifications (wood-earth firing posts, dugouts and pillboxes) instead of locking them into bunkers, while forcing the invaders to attack trenches as in World War I without armor and direct fire support. It caused heavy losses to the Soviets and repelled them for two months.

At the Battle of Sevastopol, Red Army forces successfully held trench systems on the narrow peninsula for several months against intense German bombardment. The Western Allies in 1944 broke through the incomplete Atlantic Wall with relative ease through a combination of amphibious landings, naval gunfire, air attack, and airborne landings. Combined arms tactics where infantry, artillery, armour and aircraft cooperate closely greatly reduced the importance of trench warfare. It was, however, still a valuable method for reinforcing natural boundaries and creating a line of defence. For example, at the Battle of Stalingrad, soldiers on both sides dug trenches within the ruins; as well in the Battle of Hurtgen Forest, both American and German soldiers also dug trenches and foxholes in the rugged woods of the forest which led to continuous stalemates and failed offensives that lasted for months, which was reminiscent of the trench warfare of World War I. The Battle of the Scheldt, due to the geography of the battle field greatly involved the use of trench warfare. In addition, before the start of the Battle of Kursk, the Soviets constructed a system of defence more elaborate than any they built during World War I. These defences succeeded in stopping the German armoured pincers from meeting and enveloping the salient.
The Italian Campaign fought from 1943 until the end of the war in Europe largely consisted of the Allies storming strongly fortified German lines which stretched from one coast, over the mountains to the other coast. When the Allies broke through one line, the Germans would retreat up the peninsula to yet another freshly prepared fortified line.
At the start of the Battle of Berlin, the last major assault on Germany, the Soviets attacked over the river Oder against German troops dug in on the Seelow Heights, about 50 km (31 mi) east of Berlin. Entrenchment allowed the Germans, who were massively outnumbered, to survive a bombardment from the largest concentration of artillery in history; as the Red Army attempted to cross the marshy riverside terrain they lost tens of thousands of casualties to the entrenched Germans before breaking through.
During the Pacific War, the Japanese used a labyrinth of underground fixed positions to slow down the Allied advances on many Pacific Islands. The Japanese built fixed fortifications on Iwo Jima, Okinawa, and Peleliu using a system of tunnels to interconnect their fortified positions. Many of these were former mine shafts that were turned into defence positions. Engineers added sliding armored steel doors with multiple openings to serve both artillery and machine guns. Cave entrances were built slanted as a defence against grenade and flamethrower attacks. The caves and bunkers were connected to a vast system throughout the defences, which allowed the Japanese to evacuate or reoccupy positions as needed, and to take advantage of shrinking interior lines.