ISLAMABAD, Pakistan — Imran Khan, the charismatic cricketer-turned-politician, was elected prime minister on Friday in an acrimonious vote in the lower house of Parliament that was punctuated by partisan shouting.

“Those people who have looted the country, I promise that they will be brought to justice,” Mr. Khan said in a brief speech after the vote, repeating an anti-corruption campaign theme and offering little conciliation to his adversaries.

Surrounded by loyalists as the opposition’s sloganeering grew louder, he added: “No one has ever been able to blackmail me before. I tell you please go ahead and protest and hit the streets.”

Mr. Khan, the leader of the Pakistan Tehreek-e-Insaf party, received 176 votes on Friday while his opponent, Muhammad Shehbaz Sharif of the Pakistan Muslim League-Nawaz, got 96. He is scheduled to take the oath of office on Saturday.