Elahi begun his political career after electing as the chairman of district council of Gujrat for the four years in 1983. He served as Provincial Minister for Local Government and Rural Development for a period of eight years from 1985 to 1993. He was elected as a member of the Provincial Assembly of Punjabfor the first time in 1985 Pakistani general election. He was re-elected as a member of the Provincial Assembly of Punjab for the second time in 1988 Pakistani general election. He was re-elected as a member of the Provincial Assembly of Punjab for the third time in 1990 Pakistani general election. He was re-elected as a member of the Provincial Assembly of Punjab for the fourth time in 1993 Pakistani general election and served as acting leader of the opposition in Provincial Assembly of Punjab from 1993 to 1996 in the absence of Shahbaz Sharif who had gone to the United Kingdom for medical treatment. Several cases were registered against Elahi during Bhutto government 1993-1996 and he was sent to the Adiala Jail where he spent several months. It was reported that Nawaz Sharif had promised Elahi that if PML-N win 1997 Pakistani general election, Elahi would be made the chief minister of Punjab. However, when the PML-N won the 1997 general elections. Nawaz Sharif appointed his brother Shahbaz Sharif as the Chief Minister of Punjab. To avoid the impression that Elahi was unhappy with this decision of Nawaz Sharif. he supported the Shahbaz Sharif for the position of Chief Ministership however decided not to join the provincial cabinet of Shahbaz Sharif. He was re-elected as a member of the Provincial Assembly of Punjab for the fifth time in 1997 general election and was elected as the speaker of Provincial Assembly of Punjab in 1997 where he remained until June 2001. Following the 1999 coup he was detained by the National Accountability Bureau on corruption charges. Charges were dropped following an agreement they made to defect from the Pakistan Muslim League with whom he have been part of till the ouster of PML-N government and assist President Musharraf in building PML-Q. He along with his cousin Shujaat and other dissidents left PML-N to form their own party, PML-Q. He was re-elected as a member of the Provincial Assembly of Punjab for the sixth time in 2002 Pakistani general election. Following the elections, Elahi was appointed as the chief minister of Punjab for the first time where he served from October 2002 until the dissolution of the provincial government in October 2007. In 2008 Pakistani general election, Elahi was elected as the member of the National Assembly of Pakistan for the first time and as the member of the Provincial Assembly of Punjab for the seventh time. PML-Q nominated Elahi as its candidate for the post of prime ministers of Pakistan following the 2008 general elections. In 2008, he was made the Leader of the Opposition in the National Assembly, however he quit this post later that year. He was made Federal Minister for Defence Production and Industries in Yousuf Raza Gilani cabinet. In 2011, the ceremonial post of deputy prime minister of Pakistan was created to appoint Elahi as the first deputy prime minister of Pakistan having no powers even in the absence of the prime minister of Pakistan. In 2013 Pakistani general election, Elahi ran for seat of National Assembly from the NA-105 Gujrat constituency and won it defeating candidates of PPP and PML-N. He was re-elected to the National Assembly as a candidate of PML-Q from Constituency NA-65 and NA-69 in 2018 Pakistani general election. In the same election, he was re-elected to the Provincial Assembly of Punjab as a candidate of PML-Q from Constituency PP-30. Following his successful election, he abandoned his national assembly seats in favor of the provincial assembly seat. He was named by Pakistan Tehreek-e-Insaf and PML-Q as their joint candidate for the office of Speaker of the Provincial Assembly of Punjab. On 16 August 2018, he was re-elected as Speaker of the Punjab Assembly. He received 201 votes against his opponent Muhammad Iqbal Gujjar who secured 147 votes. On 19 August 2018, he became acting governor of Punjab following the resignation of Rafique Rajwana.