Syed Ahmed Barelvi left his cannons at Amb and marched with 3,000 followers to Mayar, where he faced a much larger Barakzai force consisting of 12,000 men and 6 cannons. The battle started early in the morning and lasted for several hours. After a severe fight Sultan Mohammed Khan fled, leaving behind 80 dead. The Mujahideen casualties at the battlefield were 28, with an additional 10 being killed in other places.[5][1]
Following the battle, Ahmed Barelvi gathered 7,000 of his Hindustani Mujahideen and local tribesmen and moved to Peshawar. After a long series of negotiations Sultan Mohammed Khan agreed to surrender control of the city to Barelvi. In return Barelvi maintained him as the governor on the condition of paying tribute, despite the protests by his close companions who considered Sultan Mohammad Khan as unreliable. Barelvi stayed at Peshawar for three weeks and after finalising affairs returned to Charsadda in November, leaving behind Maulvi Mazhar Ali Khan as his deputy.[1][5] Now Barelvi was in the control of whole of Peshawar Valley as well as parts of Hazara, and took the title of Khalifa.[2]
The Barelvi's decision to keep Sultan Mohammed Khan on his position proved to be a grave mistake as in November he planned a conspiracy against Barelvi's agents in Peshawar and elsewhere, resulting in the massacre and assassinations of hundreds of his followers.[1] This incident caused Barelvi to lose hopes of establishing a foothold in Peshawar and he moved with the remaining Mujahideen to Balakot, where he was killed fighting against the Sikh forces in May next year.[4]