The court, however, disqualified Mr. Sharif for not declaring a salary from one of his son’s companies. He has said he never received that amount and was not bound to declare it on his income returns.

Since the ouster, Mr. Sharif has embarked on a forceful public campaign, claiming that he was removed as a result of political vendetta and on a weak legal argument. He has maintained that he and the ruling party are being singled out by the top court, which he claims is supported by Pakistan’s powerful military establishment. The military and the court’s justices deny the accusations.

Mr. Sharif’s messages have resonated in parts of the electorate, chiefly his base in Punjab, the province that traditionally decides the country’s political fortune. The governing party has won several recent polls with a resounding majority.

The electoral victories, though, have come at a time of increasing clashes with the Supreme Court and a more activist role by Justice Nisar. That, in turn, has raised criticism that the court is overreaching.

On Tuesday, a day before the panel’s ruling, Justice Nisar lashed out at his critics, saying in a speech that the “Constitution is higher than the Parliament.” That was widely seen as a response to remarks by Prime Minister Shahid Khaqan Abbasi, a Sharif loyalist, that the court was insulting politicians and denying lawmakers the right to legislate.

Analysts said the court verdict was a setback for Mr. Sharif but one that he could use to his advantage.

“For Nawaz Sharif, the court ruling has come at a very wrong time procedurally,” said Talat Hussain, a popular talk show host and columnist. “He was counting on having his candidates in the Senate, and now that is in a state of limbo.”