Ashraf was elected to the Senate of Pakistan from Punjab general seat as an independent candidate in by-election held on 1 March 2018. He received 298 votes against a candidate of Pakistan Tehreek-e-Insaf who secured 38 votes. Ashraf was backed by PML-N which initially nominated him but he had to run in the polls independently after the Election Commission of Pakistan declared his nomination papers cancelled following the disqualification of Nawaz Sharif by the Supreme Court of Pakistan. He took oath as Senator on 12 March 2018.