In 1826, Syed Ahmad Barelvi declared Jihad against the Sikh Empire ruled by Maharaja Ranjit Singh. The Aim of Syed Ahmad's Holy War against the Sikhs was to restore Muslim Rule and drive out the East India Company from India. Syed concentrated his military operations mostly in Khyber Pakhtunkhwa.

Syed Ahmad Barelvi initially gained the support of the Pashtun tribes for his Jihad, but as the war continued, he introduced reforms that were unpopular among the Pashtuns, leading them to withdraw their support for the movement.

In the final battle between the Mujahideen and the Khalsa Army led by Prince Sher Singh, Syed Ahmad Barelvi was killed, along with most of the Mujahideen leaders, including Shah Ismail Dehlvi, effectively ending the Jihad threat.

Names The war is also referred to as "Sayyid Ahmad's Holy War", "Syed Ahmad's Jihad",Sources:

"Jihad of Sayyed Ahmad Shahid", or "Barelvi's Jihad".

Background In the early 19th century, the Mughal Empire had disintegrated, and non-Muslim powers were rising across India. The British East India Company dominated almost all of India, except for the Sikh Empire, which ruled the Punjab and the Northwest Frontier and was under Maharaja Ranjit Singh. Many Indian Muslims viewed these new powers as oppressive “infidel” dominations that had replaced Islamic governance. Born in Rae Bareli in 1786, Syed Ahmad was influenced by the reformist teachings of Shah Waliullah's school in Delhi, which laid importnance in purifying Islam from un-Islamic innovations and resisting foreign rule. After a career as a soldier, Syed Ahmad turned to spiritual preaching and traveled across India, rallying Muslims to revive their faith and socio-political power. In 1821 he performed the Hajj pilgrimage to Mecca.

After returning to India, Syed Ahmad became convinced that Jihad was necessary to restore Muslim rule in India. The goal of the Jihad, according to the Syed, was to defeat the Sikhs and expel the East India Company. He chose to fight the Sikhs first, as they were weaker than the British East India Company and because Khyber Pakhtunkhwa provided a recruitment ground, with the Pashtuns already being subdued by the Sikhs.

Syed Ahmad migrated to the Peshawar Valley, arriving in August 1826 with his Hindustani (Indian Muslims) followers, traveling through Sindh, Kandahar, and Kabul. At that time, Peshawar was under the control of Afghan Durrani princes who paid tribute to Ranjit Singh. Syed Ahmad received a lukewarm reception from these rulers, as they were hesitant to provoke the Sikhs. Consequently, he moved his camp to the nearby Yusufzai tribal areas, where the Pashtun chiefs and villagers, long opposed to Sikh incursions, warmly welcomed his call. After gaining the support of the Yusufzai Pashtuns, Syed Ahmad initiated plans for a military campaign. He sent an ultimatum to Maharaja Ranjit Singh, urging the Sikh ruler to convert to Islam or agree to pay jizya (tribute) to an Islamic state. Syed Ahmad warned that failure to comply would inevitably lead to war but Ranjit Singh ignored this Ultimatum. Initial campaign Sardar Budh Singh Sandhanwalia was a collateral cousin of Maharaja Ranjit Singh, as were his brothers, Atar Singh and Lahna Singh. After being sent to Hazara to serve under Hari Singh Nalwa, Budh Singh was assigned to Akora, a village across the Indus River. Khattak Afghans, under the leadership of Najaf Khan, populated the majority of Akora. They retreated to the hills after the Sikhs took Peshawar. Battle of Akora Khattak

In December 1826, Sardar Budh Singh Sandhanwalia was at Akora with a force of about 4,000 men. Syed Ahmad Barelvi, at the head of an army of Hindustanis, Kandaharis, Yusafzais, and Khattaks, planned a surprise attack against the Sikh troops. The attack, led by Allahbakhsh Khan, was launched in the early hours of 21 December 1826, attacking the Sikhs off guard as they slept. Approximately 1,000 Mujahideen initially overwhelmed the opposing force, causing many Sikh soldiers to be killed or scattered in the sudden raid. According to Muslim sources, the attack was considered a victory for Syed Ahmad, with claims of hundreds of Sikh casualties compared to the loss of only a few dozen fighters on his side. However, the success was shortlived. At dawn, discipline among the tribal irregulars disintegrated, as the local Pashtuns turned to looting the Sikh camp instead of securing the battlefield. This gave the Sikh soldiers time to regroup and counter-attack. In the chaos that followed, Syed Ahmad’s core Hindustani fighters and a few loyal Pashtuns had to beat a fighting retreat, suffering losses as they withdrew.

Proclamation as Imam After the Battle many Pashtun tribes joined the movement of Syed Ahmad Barelvi and pledged their allegiance (Bay'ah) to his call for jihad. Among these were the Khadi Khan, the eminent chief of the Mandanr tribe from Hund, who became one of the prominent lieutenants of Syed Ahmad. He was later joined by Ashraf Khan of Zaida, who continued to be one of the closest associates of Syed Ahmad till his death.

On January 11, 1827, a gathering took place in Akora, attended by important leaders of the Ghazi forces and prominent local figures. It was decided to unite Muslims from both sides of the Indus River, and Syed Ahmad was proclaimed an Imam by his followers. From then onwards, the Hindustani Mujahideen started to call him Amir al-Mu'minin (Commander of the Faithful).

The Mujahideens planned to attack Hazro, a significant trading center in Sikh territory, during Syed Ahmad's stay at Bazar, Hund. Despite a small garrison and single cannon, supporters argued that capturing Hazro was crucial for achieving the movement's goals, even with its small defenses.

Battle of Hazro A group of local Pashtuns stormed Hazro, taking the fortified building and sacking the mandi but the Sikh troops counterattacked and inflicted heavy losses on the Pashtuns. The majority of them escaped, and many were slain in the process. Syed Ahmad ensured the escape of the surviving Mujahideen by sending soldiers to rescue them. Sardar Budh Singh Sandhanwalia was able to maintain his position in spite of difficulties, and just two Hindustani Mujahideen were slain. Eventually, the Ghazis retreated to their hiding spots.

Battle of Shaidu

Pashtun tribes from various areas began to gather under the command of Syed Ahmad Barelvi, and in two months, their number reached 100,000 men. The Barakzai chiefs of Peshawar joined the movement, and their army consisted of 20,000 men and 8 guns. In response, a Sikh force under Sardar Budh Singh Sandhanwalia was sent concentrated at the village of Pirpai. The Sikh army, comprising about 10,000 troops and 12 cannon, was reinforced by Raja Gulab Singh, Raja Suchet Singh, and Atariwala Sardars. Budh Singh was able to obtain the neutrality of the Barakzai chief of Peshawar through diplomatic negotiations which the Mujahideens saw as betrayal.

In March 1827, the two sides met in the pitched Battle of Shaidu. At first, the Mujahideen comprising Syed Ahmad's Hindustani fighters and several tribal militias secured an advantage over Budh Singh's Sikh regiments, while Yar Muhammad's Peshawari contingent held back. Sensing Sikh lines wavering, Syed Ahmad’s allies pressed forward. But at the critical moment, Yar Muhammad suddenly withdrew his 20,000 men from the field, even spreading panic. The Sikh artillery inflicted heavy losses on the enemy, forcing them to retreat. It is estimated that nearly 6,000 Mujahideen were killed or wounded in the battle. The Battle ended in a Sikh victory. Syed Ahmad Barelvi himself took shelter in the Swat hills the jihad movement suffered a crushing defeat. In recognition of the Sikh triumph, Maharaja Ranjit Singh sent congratulatory presents to Budh Singh Sandhanwalia and the other leaders.

Recovery The first, fast wave of the jihad movement in the Frontier ended with the loss at Shaidu. The steadfast commitment of his followers from Bengal, Bihar, Hindustan, and Kandahar allowed the movement to continue even though the loss and Syed Ahmad's declining health threatened to put an end to it. A more restrained and measured phase of the jihad movement in the area emerged as a result of this difficult period. Consolidation of power After the defeat at Shaidu, Syed Ahmad Barelvi took refuge with Fatah Khan of Panjtar, a staunch opponent of Sikh rule. With the support of Fatah Khan, Syed Ahmad began consolidating his power in the area by forcing the neighboring tribal chiefs to unconditionally support his jihad against the Sikhs. This campaign included the coercion or subjugation of leaders like Mir Babu Khan of Sadhum and Ahmad Khan of Hoti, the latter being killed for his weak commitment. Syed Ahmad's influence was extended over the Yusafzai Valley and tribes such as the Afridis, Mohmands, and Khalils were won over to his cause against the Sikhs. Missionary activities Syed Ahmad also undertook long missionary tours of Buner and Swat, persuading the local people to unite, give up social and religious practices he deemed un-Islamic, and support his cause. Letters were dispatched to neighboring rulers, including those of Chitral, Kashmir, and Bukhara, seeking alliances and cooperation. More importantly, he gained the support of discontented leaders in Hazara, where resentment against the harsh rule of Hari Singh Nalwa, the Sikh general and governor, was growing.

Kashmir had a central place in Syed Ahmad's strategic plans. Capture of this region would give him a secure and resource-rich base with its natural defenses and majority Muslim population. Syed Ahmad had earlier stated his intention to move toward Kashmir once his position in Peshawar was fully secured, the ruler of Chitral and several other local chiefs promising cooperation to that end. In preparation for this campaign, he positioned himself in Panjtar, while simultaneously dispatching Shah Ismail on a reconnaissance and preaching mission to the Pakhli area. Shah Ismail's endeavors in Amb and Sittana effectively enhanced support for the movement. Recall of Shah Ismail Syed Ahmad Barelvi's recall of Shah Ismail to Panjtar in late 1827 marked the end of this phase of the Jihad movement. The reason for his recall is still up for debate. Syed Ahmad's intention to deal with the dangers posed by Barakzai leaders, who were impeding the passage of Mujahidin caravans from India and mobilizing local tribes against him, might be one explanation. Some caravans reportedly experienced delays of up to two months when passing across a pass, most likely between Ziarat Kaka Sahib and Kohat.

Second campaign In order to overcome the Barakzai chiefs of Peshawar, Syed Ahmad Barelvi gathered money through moneylenders and looked for tribal backing. The Barakzais barred reinforcements and drove out Mujahideen supporters for betraying their loyalty. Syed Ahmad stepped up his jihad efforts after consulting with tribes and obtaining a fatwa. He intended to take Peshawar in order to eradicate the Barakzais.

Battle of Utmanzai (1828) Syed Ahmad encountered numerous challenges in his efforts to build coalitions and resist the Barakzai leaders. The Khyber chiefs weakened his campaign by withdrawing their support after initial agreements. The disunity led to the Battle of Utmanzai, where Yar Muhammad Khan intercepted Syed Ahmad's forces near the Kabul River. As the battle raged throughout the day, some of Syed Ahmad's followers defected to Yar Muhammad Khan's side. Facing mounting losses, Syed Ahmad and his troops were forced to retreat under the cover of night. Battle of Haidru