A politician who is under investigation for fraud and presided over the collapse of Pakistan's electricity supplies was elected the country's prime minister on Friday.

Capping a week of political chaos, Raja Pervaiz Ashraf won enough votes in Pakistan's National Assembly to lead the government as it attempts to limp to the end of its term in office.

After the vote rose petals were thrown over Ashraf as he walked triumphantly into the chamber, greeting supporters and making his way to the seat reserved for the prime minister.

"I will do my best to make sure I live up to the example set by those who have come before me," he said.

The successful rallying of its coalition partners to vote for Ashraf represented a success of sorts for the Pakistan People's party (PPP), which has suffered a series of setbacks in recent days. On Tuesday the country's supreme court disqualified Yousaf Raza Gilani as prime minister over his refusal to reopen fraud investigations into president Asif Ali Zardari.

Critics of the court and its leader, the chief justice Iftikhar Muhammad Chaudhry, fear it is targeting the government and overreaching its constitutional powers. Some described Gilani's ousting as a "judicial coup".

His disqualification also meant the troubled country has not had a cabinet for almost a week. And it added yet another distraction to critical issues the government has struggled to overcome, including Taliban militancy on its western border and its failing relations with the US.

Then, on Thursday, an arrest warrant was issued against the PPP's preferred candidate to take over as head of government, Makhdoom Shahabuddin, almost as soon as his name had been proposed.

The involvement of the military-controlled Anti Narcotics Force in pushing for the warrant has raised suspicions that the army is also flexing its muscles against the government. The PPP hopes to become the first in Pakistan to complete a full five-year term without collapsing or being swept away by a military coup.

However the party is unlikely to enjoy a smooth ride in the months before March, when an election must be called.

Ashraf is likely to be embroiled in the same legal battle as Gilani if, as expected, the supreme court reissues its demands for the prime minister to pursue money laundering allegations against Zardari.

Some analysts have also questioned whether Ashraf is the right man to lead the party into fresh elections given his previous cabinet job as water and power chief coincided with crippling electricity shortages.

Severe power cuts and sweltering summer weather have triggered waves of violent protests and rioting. "Load shedding" – or power cuts – is likely to be a key issue in the election. "It is extraordinary that we have violent riots across the Punjab and we have this former power minister becoming prime minister when millions of people are enraged by precisely that problem," said Mehreen Zahra-Malik, an assistant editor of The News. She said he owed his selection simply to his unswerving loyalty to Zardari.

"At this stage it is not about how good you are, or what you did in your previous tenure, but how loyal you are to the boss," she said.

Ashraf may also face legal challenges from a national anti-corruption body over his alleged involvement in a scandal involving kickbacks from "rental power plants" – private electricity companies supplying the Pakistani grid.

An investigation is already under way into the man the media has dubbed Raja Rental. "The candidature of Raja Pervez Ashraf for PM shows the utter contempt Asif Zardari has for the people of Pakistan," tweeted Imran Khan, the former cricketer and rising opposition politician.