Imran Khan put himself in the firing line after his finance minister lost a high-profile Senate seat.
Pakistani Prime Minister Imran Khan survived a vote of confidence from parliament on Saturday.
Khan volunteered to seek parliament's confidence after his ruling party's Finance Minister Hafeez Sheikh lost a high-profile Senate seat election earlier this week.
Khan secured 178 votes, against the 172 required to win confidence, the speaker of the house announced.
The vote went ahead without the 160 opposition members who announced the day before plans to boycott the session.
Opposition members argue that the Senate seat defeat was sufficient to show that Khan no longer enjoyed the confidence of the house. In their opinion, this meant the vote of confidence was unnecessary.
"An illegal session is being called to cheat the Pakistani people," former prime minister and opposition leader Shahid Khaqan Abbasi told media and protesting opposition leaders outside the parliament building on Saturday.
While opposition leaders were protesting, local media footage appeared to show a crowd of government supporters surround and attack them, news agency Reuters reported.
Some footage showed an attack on Abbasi, a female opposition leader and an opposition senator.
Sheikh's defeat was a setback for Khan. He criticized the country's Election Commission, claiming it had failed to ensure a free and fair vote for the Senate and saying that some 15 or 16 lawmakers from his party allegedly "sold" their vote to the opposition candidate.
Angered over Khan's criticism, the commission on Friday fired back. It said every political party and politician needs to "have the spirit to accept defeat" when it comes and not resort to mudslinging over election losses.
kmm/mm (Reuters, dpa, AP)