Imran Khan was dismissed on Sunday as Pakistan prime minister after losing a no-confidence vote in parliament following weeks of political turmoil.
It was not immediately clear when a new premier will be chosen, but Pakistan Muslim League-N (PML-N) chief Shehbaz Sharif was almost certain to be picked to lead the nuclear-armed nation of 220 million people.
No prime mister has ever served a full term in Pakistan, but Khan is the first to lose office this way.
Acting speaker Sardar Ayaz Sadiq said 174 lawmakers had voted in favour of the motion, "consequently the vote of no confidence has passed".
Khan, 69, tried everything he could to stay in power -- including dissolving parliament and calling a fresh election -- but the Supreme Court deemed all his actions illegal last week, and ordered the assembly to reconvene and vote.
There was drama right until the midnight deadline ordered by the Supreme Court, with the speaker of the assembly -- a Khan loyalist -- resigning at the last minute.
In the end the session continued through to Sunday with a replacement.
"We will put a balm on the wounds of this nation," Sharif said immediately after the result was announced.
Khan, who was not present, lost his majority in the 342-seat assembly through defections by coalition partners and members of his own party, and the opposition had needed just 172 votes to dismiss him.
- Militancy on the rise -
Whoever takes over will still have to deal with the issues that bedevilled Khan -- soaring inflation, a feeble rupee and crippling debt.
Militancy is also on the rise, with Pakistan's Taliban emboldened by the return to power last year of the hardline Islamist group in neighbouring Afghanistan.
Tempers rose earlier when Sharif insisted a vote be held immediately -- as ordered by the Supreme Court on Thursday -- but Khan loyalists demanded discussion first on their leader's claims there had been foreign interference in the process.
Foreign minister Shah Mehmood Qureshi accused the opposition of leading the country down a dangerous path.
"History will expose all those, who set the stage for this move to topple the government," he said, to chants of "vote, vote" from the opposition.
Khan insists he has been the victim of a "regime change" conspiracy involving the United States.
He said the PML-N and the Pakistan Peoples Party (PPP) -- two normally feuding dynastic groups who joined forces to oust him -- had conspired with Washington to bring the no-confidence vote because of his opposition to US foreign policy, particularly in Muslim nations such as Iraq and Afghanistan.
He also accused the opposition of buying support in the assembly with "open horse-trading... selling of lawmakers like goats and sheep".
How long the next government lasts is also a matter of speculation.
The opposition said previously they wanted an early election -- which must be called by October next year -- but taking power gives them the opportunity to set their own agenda and end a string of probes they said Khan launched vindictively against them.
Local media quoted an election commission official as saying it would take them at least seven months to prepare for a national vote.
Publicly the military appears to be keeping out of the current fray, but there have been four coups since independence in 1947 and the country has spent more than three decades under army rule.