Judge Brann said the claims by the Trump campaign that the guarantee of equal protection had been violated were "like Frankenstein's Monster... haphazardly stitched together from two distinct theories in an attempt to avoid controlling precedent."
The Trump campaign responded by issuing a statement blasting the "Obama-appointed judge" while vowing to fight on all the way to the Supreme Court.
"Today's decision turns out to help us in our strategy to get expeditiously to the US Supreme Court," Trump campaign attorneys Rudy Giuliani and Jenna Ellis wrote in their statement.
"Although we fully disagree with this opinion, we're thankful to the Obama-appointed judge for making this anticipated decision quickly, rather than simply trying to run out the clock."
Trump had argued that the US Constitution's guarantee of equal protection under the law was violated when Pennsylvania counties took different approaches to notifying voters before the election about technical problems with their submitted mail-in ballots.
Pennsylvania Secretary of State Kathy Boockvar and the seven Biden-majority counties that the campaign sued had argued Trump had previously raised similar claims and lost.
They told Brann the remedy the Trump campaign sought, to throw out millions of votes over alleged isolated issues, was far too extreme, particularly after most of them had been tallied.
"There is no justification on any level for the radical disenfranchisement they seek," Boockvar's lawyers wrote in a brief filed on Thursday (US time).
Pennsylvania Attorney General Josh Shapiro, a Democrat, tweeted shortly after Brann's ruling, saying: "Another one bites the dust."
The state's 20 electoral votes would not have been enough on their own to hand Trump a second term. Counties must certify their results to Boockvar by Monday, after which she will make her own certification.
Democratic Governor Tom Wolf will notify the winning candidate's electors they should appear to vote in the capitol on December 14.