Ashraf was administered the oath of office by President Asif Ali Zardari tonight, hours after he was elected as the new Prime Minister by the National Assembly.
A new federal cabinet was also sworn in at the Presidency, where 27 federal ministers and 11 ministers of state took oath.
The 61-year-old loyalist of the Bhutto family was pitchforked into the hot seat after the original choice Makhdoom Shahabuddin faced an arrest warrant yesterday. But the new leader himself is dogged by corruption charges relating to his tenure as Power Minister.
The 342-member National Assembly chose Ashraf as the country's 25th Prime Minister with 211 votes, against opposition PML-N nominee Sardar Mehtab Ahmed Khan Abbasi who got 89 votes.
Addressing the National Assembly following his election, Ashraf promised to keep bettering of ties with India as one of his foreign policy priorities.
He said Pakistan will work to strengthen the dialogue process that is already underway to resolve problems like the Kashmir issue.
Several members of Gilani's cabinet were re-inducted as ministers, including Hina Rabbani Khar, Qamar Zaman Kaira, Naveed Qamar, Khursheed Shah, Farooq Sattar and Makhdoom Shahabuddin, who was the ruling Pakistan People's Party's original candidate for the post of premier.
Shahabuddin had to bow out of the race yesterday after a special court issued an arrest warrant for him in connection with alleged irregularities in the import of a controlled drug during his tenure as Health Minister.
The outstanding swearing-in ceremony was attended by political leaders, several Governors and Chief Ministers, the three service chiefs, diplomats, the Speaker of the National Assembly, the Chairman of the Senate and Gilani.
The election of the new premier was necessitated because a bench of the Supreme Court headed by Chief Justice Iftikhar Chaudhry disqualified Gilani on Tuesday in response to several petitions that had challenged the National Assembly Speaker's decision not to disqualify him following his conviction for contempt.
The apex court ruled that the post of premier had been vacant since Apr 26, when another seven-judge bench had convicted Gilani of contempt for refusing to reopen graft cases in Switzerland against Zardari.
Ashraf's election is seen by experts as a taunt to the assertive judiciary. It might irk the Supreme Court, which had ordered the government to take legal action against him for alleged corruption case.
Moreover, the new Prime Minister is also likely to face demands for reopening graft cases against Zardari from the apex court.
Ashraf, who belongs to a royal family of Rawalpindi in Punjab, was elected in a two-way contest during a special session of Parliament after three other candidates - Shahabuddin and Qamar Zaman Kaira of the PPP and Jamiat Ulema-e-Islam chief Maulana Fazlur Rehman - withdrew from the race. The eight members of the Jamiat Ulema-e-Islam did not vote in the poll.
"I am a middle class political worker. I am a human being, I can make mistakes, but I understand the chair that I have been offered today is a chair of martyrs," Ashraf, whose government has another eight months when the next general elections are due, said.
"Whatever time I have at disposal, I promise to work to the best of my ability and to devote myself to the people who need good governance and clean governance... The flame that has passed on to me, I will not let it die," he said while addressing the National Assembly.
Ashraf also lauded Gilani for working to ensure the supremacy of democracy and legislature, and said parliament was the last hope for aspirations of the people.
Zardari congratulated Ashraf and said his "election as PM is an indication of the nation's confidence in democracy".
However, opposition PML-N leader Nawaz Sharif described Ashraf's election as 'not less than a tragedy for the country' and questioned the logic behind it.
"Why the government brings forward ill-reputed persons. I feel ashamed even of taking names of such persons... It is surprising that President Zardari has nominated a person who is facing corruption charges," he said.
Zardari directed the new premier to focus on resolving the problems of the people, including a crippling power shortage that has triggered violent protests.
Zardari called on the new premier to give "foremost attention" to addressing the problems of the people.
He said the power shortage should be addressed on a priority basis.
Zardari identified inflation, unemployment and law and order as other issues of "great concern" to the people.
"I am confident that the new government headed by Prime Minister Raja Pervez Ashraf will address all these issues with zeal and determination," the President said.
Zardari began his speech by addressing Gilani.
"I also want to place on record our deep appreciation for Yousuf Raza Gilani... for upholding the supremacy of the parliament and the Constitution," Zardari said as the gathering gave Gilani a standing ovation.
Congratulating Gilani for all that he did for the people "despite so many difficulties and challenges", Zardari said the former premier had paid a "very high personal price" but "stood firmly to protect the democratic principles, the supremacy of the parliament and of the Constitution".
The ruling Pakistan People's Party and democratic forces will always stand by Gilani, Zardari said.
In an apparent reference to the apex court's verdict against Gilani, Zardari said, "The ultimate court is the court of the people, the ultimate verdict is pronounced by history and the people and history will give the verdict sooner than later".