It is not clear whether Mr Sharif plans to appeal
Former Pakistani Prime Minister Nawaz Sharif has been barred from running in a parliamentary by-election this week.
The high court in the city of Lahore upheld an earlier ruling that Mr Sharif was ineligible to stand because of a 1999 court conviction.
Earlier this month the country's election commission had appeared to clear him to take part.
Correspondents say Monday's ruling is a major political setback for Mr Sharif. It is not clear whether he will appeal.
"The decision is based on conspiracy. It's a political decision," a spokesman for Mr Sharif's PML-N party, Siddiqul Farooq, told Reuters news agency.
The PML-N emerged as the second largest party in general elections in February that saw President Musharraf's allies routed.
Neither Mr Sharif nor Pakistan's other top politician, PPP leader Asif Ali Zardari, ran.
Mr Sharif was barred from standing because he had been convicted over the 1999 hijacking of a plane carrying then army chief Gen Musharraf.
The alleged hijacking was part of events which led to Gen Musharraf ousting Mr Sharif in a coup.
Earlier in June, it appeared the election commission had cleared the way for the former premier to stand in the by-election, but court petitions were subsequently lodged challenging his nomination.
The BBC's M Ilyas Khan in Karachi says Mr Sharif's position is complicated because he does not recognise the country's senior judiciary.
Mr Sharif says the judges were unconstitutionally appointed after President Musharraf sacked their predecessors during emergency rule late last year.
If he goes to the Supreme Court he will be seen as legitimising the judges, who may in any event turn down his appeal, our correspondent says.
The PML-N is likely to increase pressure on the PPP to reinstate the sacked judges, putting further strain on their post-election alliance.
Eight national assembly seats and 30 provincial ones will be contested on 26 June.
They are being held for a number of reasons.
Votes in some seats were postponed because of security concerns, in others because candidates had died, and in several more because candidates were successful in more than one constituency.
In that instance, they must choose which seat to represent, prompting by-elections elsewhere.