Ali Masjid is the narrowest point of the Khyber Pass. It is located in the Khyber Agency of the Federally Administered Tribal Areas (FATA), Pakistan. It is located around 10 miles (16 km) east of the city of Landi Kotal (West of Peshawar) and has an elevation of 3,174 feet (967 m). The width of the Khyber near Ali Masjid was earlier too narrow for two fully laden camels to pass each other but since has been widened.
It was named in memory of Ali, the cousin of the Islamic prophet Muhammad. A mosque and a shrine has been built here in the memory of Ali, who visited this place according to a local tradition. There is also a huge boulder which carries the marks of a hand believed to be that of Ali.
Ali Masjid is located at the narrowest point in the Khyber Pass. It contains a shrine to ʻAlī ibn Abī Ṭālib (circa 600–661) the cousin and son-in-law of Muhammad.
A fortress was built on the site in 1837 by the Afghan amir, Dōst Mohammad Khān (1793–1863). The shrine and fort are located in extremely rugged terrain overlooking a deep gorge.
The British established their own fort on the site in the nineteenth century, commanding a strategic view over the Khyber pass. The fort has a small cemetery which contains the graves of British soldiers who fell in the second Afghan War. The valley walls bear insignias of regiments that have served here.
While going on the trading route between Kadam and Ali Masjid people would drop out of the line of march to breathe a hurried prayer at the shrine.Upon the height above the mausoleum rests the impregnable fort, which has been carried by assault more than once, and was burned by the British after its last capture.
Ali Masjid was the scene of battles during the Anglo-Afghan wars. In 1842 during the First Anglo-Afghan War, the fort was garrisoned by the British. During the disastrous retreat from Kabul, a relief force under Colonel Charles Wild was attacked by Afghan troops of Akbar Khan at the entrance of the Khyber pass and forced to fall back. The fort garrison was also forced to evacuate Ali Masjid fort and fall back to Jamrud. During the Second Anglo-Afghan War, the Peshawar Valley Field Force under General Sir Samuel Browne, during the advance on Kabul in 1878, captured this fort which was held by the Afghans under Faiz Muhammad.