Judge Matthew Brann said the suit, which rested on allegations of irregularities, was "without merit".
The move paves the way for Pennsylvania to next week certify Joe Biden's win - he leads by more than 80,000 votes.
It is the latest blow to Donald Trump, who is trying to overturn his loss in the 3 November presidential election.
He has refused to concede and made allegations of widespread electoral fraud, without providing any evidence.
The lack of a concession has upended the process that normally follows a US election.