Ahsan returned to Pakistan in 1967. He joined Pakistan Peoples Party and began his political career in 1970s. He was elected as the member of the Provincial Assembly of the Punjab for first time on the ticket of PPP in by-elections held following the Pakistan General elections of 1977 from Gujrat constituency. He was inducted in the provincial cabinet of Punjab and was appointed as the Provincial Minister for information, planning and development. Ahsan was in his twenties during his tenure as provincial minister. He resigned from the provincial cabinet and left PPP following the incident in which Punjab Police opened fire on a rally of lawyers during the Pakistan National Alliance demonstrations against the alleged rigging of elections by the PPP government in 1977. Ahsan joined Tehrik-e-Istiqlal. He rejoined the PPP following the Operation Fair Play and actively became involved with the Movement for the Restoration of Democracy and for his participation in the MRD, he was repeatedly imprisoned. He was reportedly jailed for two years during Zia -ul-Haq presidency. He was elected as the member of the National Assembly of Pakistan on PPP ticket for the first time in Pakistan General elections of 1988 from Lahore constituency. He was inducted into federal cabinet and was appointed as the Minister for Law and Justice, along with the additional portfolio of the Ministry of Interior and Narcotics Control. He was re-elected as the member of the National Assembly of Pakistan on PPP ticket for the second time in Pakistan General elections of 1990 from Lahore constituency. He lost the Pakistan General elections of 1993 to Humayun Akhtar Khan of Pakistan Muslim League. In 1994 he was elected as the member of the Senate of Pakistan for the first time representing PPP, where he sat as Leader of the Opposition until 1999. In Pakistan General elections of 2002, he ran for the membership of the National Assembly on PPP seat from two constituencies. He was re-elected as the member of the National Assembly for the third time from constituencies of Bahawalpur and Lahore. He retained his Lahore seat. Ahsan did not run in the Pakistan General elections of 2008 due to his involvement in the Lawyers' Movement for the restoration of deposed judges. Ahsan was elected as the member of the Senate for the second time in the 2012 Pakistani Senate election on technocrat seat representing PPP. In 2013, he reportedly resigned from Senate membership. In 2013, Ahsan become opposition leader in the Senate. In 2015, he for the second time became opposition leader in the Senate. In late August 2018, Ahsan was nominated by the PPP as a candidate for the 2018 presidential election according to media reports. On 4 September 2018, he clinched 124 electoral votes behind Arif Alvi and Fazal-ur-Rehman in the election.
Ahsan is the author of the book The Indus Saga and the Making of Pakistan and its Urdu translation, Sindh Sagar Aur Qyam-e-Pakistan which presents the cultural history of Pakistan. He has also co-authored the book Divided by Democracy with Lord Meghnad Desai of the London School of Economics.