The revolutionaries felt that soft words of non violence could not win India its Independence and therefore they wanted to make use of bombs, revolvers and other weapons to instill fear in the hearts of the British empire. The British Empire was large and strong. The withdrawal of the non cooperation movement united revolutionaries scattered in the country. This revolutionary movement required money to support its need. One day while traveling on a train from Shahjanpur to Lucknow Ram Prasad noticed stationmaster bringing money bags into the guards van. This was a beginning of a Dacoity called Kakori train robbery.
To give a fillip to their movement and buy arms and ammunition to carry out their activities, the revolutionaries organised a meeting on August 8, 1925 in Shahjahanpur. After a lot of deliberations it was decided to loot the government treasury carried in the trains. On 9 August 1925 Ashfaqulla and other revolutionaries, namely Pandit Ram Prasad Bismil, Rajendra Lahiri, Thakur Roshan Singh, Sachindra Bakshi, Chandrashekar Azad, Keshab Chakravarthy, Banwari Lal, Mukundi Lal, Manmathnath Gupta looted the train carrying British government money in Kakori near Lucknow.
On the morning of 26 September 1925, Pandit Ram Prasad Bismil was caught by the police and Ashfaq was the only one untraced by the police. Ashfaq went into hiding and moved to Banaras from Bihar where he worked in an engineering company for 10 months. Ashfaq wanted to move abroad to learn engineering to further help the freedom struggle and so he went to Delhi to find out ways to move out of the country. He took the help of one of his Pathan friend who in turn betrayed him by informing the police about his whereabouts. Tasadruk Khan then superintendent of police tried to play the caste politics with Ashfaq and tried to win him over by provoking him against Hinduism but Ashfaq was a strong willed Indian who surprised Tasadruk Khan by saying "Khan Sahib, I am quite sure that Hindu India will be much better than British India."
Ashfaqullah Khan was detained in the Faizabad jail. A case was filed against Ashfaqullah. His brother Riyasatullah was his counsel who fought the case till the very end. While in jail, Ashfaqullah recited the Quran. The case for the Kakori dacoity was concluded by awarding death sentence to Pandit Ram Prasad Bismil, Ashfaqulla Khan, Rajendra Lahiri and Thankur Roshan Singh. The others were given life sentences.
By an eyewitness account, on a Wednesday, four days before he was hanged, two English officers looked into the cell where Ashfaqulla Khan was lodged. He was in the middle of his namaz. "“I’d like to see how much of that faith remains in him when we hang the rat,” quipped one of them.
On Monday, 19 December 1927, Ashfaqullah Khan is known to have taken two steps at a time, as he walked up to the post. When his chains were released, he reached for the rope and kissed it. "My hands are not soiled with the murder of man. The charge against me is false. God will give me justice. la ilahi il allah, mohammed ur rasool allah." The noose came around his neck and the movement lost one of its shining stars.