On 29 October 2003, Lt-Gen. Shahid Aziz ordered the NAB agents to detained him from the Parliament Building, and was later taken in to custody by the Military Police on charges of inciting mutiny leveled by President Pervez Musharraf. Hearings of his trials were held in the Adiala Prison and the session court at the Lahore High Court, which raised doubts among human rights groups about its fairness. On 12 April 2004, he was sentenced to 23 years in prison for inciting mutiny in the military, forgery, and defamation. The verdict was widely criticized in Pakistan and was considered as a wilful miscarriage of justice by the Musharraf administration, and the ARD and the MMA termed this verdict to be politically motivated by the ruling junta with malicious intent, declaring him to be a political prisoner. He was transferred and held in the Central Jail Lahore where he penned and authored a critically acclaimed political book, Haan Mein Baghi Hun! (lit. "Yes, I am Rebel!") where he exposed the military's intervention in the politics and the foreign relations with the United States. He also authored the Takhtaey-e-Daar Kay Saaey Talay (lit. "Under the shadow of Hanging board"). On 3 August 2007, a three-member bench of the Supreme Court of Pakistan under Chief Justice Iftikhar Chaudhry granted him bail after serving approximately three and a half years in prison. On 4 August 2007, Hashmi, with among PML(N) leaders, were released but again placed under arrest at the declaration of a state of emergency on 3 November 2007  During the general elections held in 2008, Hashmi successfully defended the NA-55 (Rawalpindi-VI) constituency where he notably defeated PML(Q)'s Rashid Ahmed but decided to retain his NA-148 Constituency against the wishes of Nawaz Sharif. He spoke against of the strategic partnership act offered by the United States, and released a very strong reaction on Inter Services Public Relations, which he termed the Kerry-Lugar Bill, an interference on part of Americans in country's intelligence community. He reported quoted: "if there is anything that needs to be corrected, Pakistan will do it herself. Pakistan Army should stay within its limits... We will protect our military if it ensures playing the role assigned to it." Over the issue of the Memogate scandal that implicated the former President Asif Ali Zardari and Parliament's failure for its investigation, Hashmi reportedly Hashmi submitted his resignation from Parliament, claiming that "this parliament is a dummy and not passing real legislation" on 7 May 2011.