1st Battle of El Alamein-the advance of the forces of the Axis were stopped in Africa. In the 2nd Battle, the German-Italian forces in Africa suffered such losses that they lost the offensive capacity
Details of the main battle may be found in this source:
Second Battle of El Alamein
The victory of the Axis Forces in the Battle of Gazala (May and June of 1942), which led to the capture of the port Tobruk in Libya, opened the possibility of an advance to grab Egypt, following the retreat of the British 8th Army.
So Field Marshal Erwin Rommel (leading the Afrika Korps , the Panzerarmee Afrika and Italian divisions) launched the offensive that was delayed, next to the Egyptian border, in the Battle of Mersa Matruh, what allowed time to the British to prepare their defenses in El Alamein, within 80 km (50 mi) of Alexandria.
So when the Axis Forces reached positions next to El Alamein, they where detained by the British forces (in the 1st Battle of El Alamein).
Then the Axis Forces, with logistic problems, after without success trying to envelop the British in the Battle of Alam el Halfa, established a deffensive line. With reinforced forces the British, commanded by Lieutenant-General Bernard Montgomery, were able to break the German-Italian line; unable to hold position, and sustaining great losses, the German-Italian forces retreated almost unopposed out of Egypt.
This battle marked an important turning point of the Western Desert Campaign and it was the first major victorious offensive of the Western Allies.