The North Africa Campaign, which lasted from 1940 into 1943, was the primary front for the Western Allies during this period. Without a foothold on mainland Europe, here they hoped to gain a platform from which to invade Italy. Their eventual victory in North Africa was perhaps because it was the Western Allies only front at the time, while the Germans were preoccupied in Eastern Europe.
The North Africa Campaign began after Italy declared war on Britain and advanced its soldiers into Egypt. The Italians were aiming to expand their empire in Africa. However, Britain's Operation Compass turned the tables on the Italians. Under Wavel the British and Commonwealth armies pushed the Italians back into Libya, where more than 100,000 troops surrendered to Britain.
With that victory Britain gained much in the way of captured military equipment. However, the advance stopped short of pushing the Italians completely out of Egypt. The battles in Greece diverted some divisions away from the North Africa Campaign. In addition to this, the Axis regrouped when the Reich sent Rommel and number of German divisions to organize the Afrika Korps.
As such, in 1941 Britain lost its position in Libya. Rommel's advances pushed them back into Egypt. This with the exception of Tobruk where U.K. troops held out to Rommel's armies. Holding Tobruk prevented Rommel from making further advances into Egypt until the Battle of Gazala in 1942. There the Axis took Tobruk and captured fuel and other supplies in the process.
However, the Allies reshuffled their command. As the Battle of El Alamein approached, Montgomery became commander of the British Army in North Africa. This was perhaps a turning point, as from here the war swung in the Allies favor.
The Second Battle of El Alamein effectively began on October 23, 1942. Then the British began a large artillery bombardment over German lines. The 13th Division struck in the south, whilst Allied engineers in the north began to clear minefields so that armored divisions and tanks could pass through.
By October 25 the Eighth Army had effectively cleared a path through the minefields, albeit with heavy losses. Only then did the first armored divisions pass through and begin to have more impact in the battle as the Allies advanced toward Point 29. They were also supported by Allied airstrikes over German and Italian positions.
To retake Point 29, the Afrika Korps dispatched many of its reserves. Artillery and aerial bombardments halted German and Italian divisions. Elsewhere, the British reinforced the Woodcock and Snipe positions in Egypt. Here Allied troops dug in, whilst U.K. divisions further northward around Point 29 began to advance by the 28th.
On November 2 a new Allied advance toward Tel el Aqqaqir began. Allied artillery and aircraft bombarded Tel el Aqqaqir before their infantry divisions began to move in. German and Italian tanks were wiped out in number as Britain maintained the advance. Outnumbered by Allied tanks, the first Axis divisions withdrew.
By November 4 the Afrika Korps' lines began to collapse. Three Allied armored divisions breached the lines and took Tel el Aqqaqir. Now the Afrika Korps began a general retreat from El Alamein, and the battle was effectively over. By November 11 Britain had pushed most of the Axis troops out of Egypt, leaving the way clear for U.K. soldiers to occupy Tobruk, which had been previously been lost in 1942.
The arrival of fresh U.S. troops and equipment during Operation Torch in late 1942 made an Allied victory all the more likely. In contrast, the Axis armies were lacking reinforcements. Consequently, by the end of 1942 the Allies had all but won the desert war and had military superiority in North Africa.
As such, the Allies won the war in the desert at El Alamein where Commonwealth troops thwarted Rommel from making further advances. Allied changes in command also made some difference, along with the British Ultra code breaking that deciphered Axis military plans and the sinking of the Afrika Korps' supplies in the Mediterranean. So the British had held the line, and with increasing support from the USA victory was all but assured in Tunisia by 1943.