He was a member of the National Assembly of Pakistan from June 2013 to May 2018 and again from August to September 2018. A founding member of Pakistan Tehreek-i-Insaf (PTI), Alvi was elected as President of Pakistan on 4 September 2018 following the presidential election.