U.S. District Judge Paul Diamond said there were at least six grounds to reject the lawsuit filed by Jill Stein, who received less than 1 percent of the votes in the state. The suit was opposed by Trump, the Pennsylvania Republican Party and the Pennsylvania attorney general's office.
"Most importantly, there is no credible evidence that any 'hack' occurred, and compelling evidence that Pennsylvania's voting system was not in any way compromised," Diamond wrote.
The judge said granting the motion would "make it impossible" for Pennsylvania to certify its results for the Electoral College by the Tuesday deadline. The state has 20 Electoral College votes.
He also said the lawsuit suffered from a "lack of standing, the likely absence of federal jurisdiction and the plaintiff's unexplained, highly prejudicial delay in seeking a recount." Also, he wrote the plaintiffs had not met any requirements to issue a mandatory emergency injunction.
Stein was denied in county and state courts.
The Green Party posted on Twitter after the decision: "Our elections will remain tainted until we get money out of them, abolish the electoral college, & implement proportional representation."
Several Green Party members didn't want to be part of the suit.
Many signed on to a letter by Dr. Margaret Flower, a defeated candidate for U.S. Senate in Maryland, who wrote on her website: "as a candidate, Dr. Stein has the right to call for a recount. However, we urge the GPUS to distance itself from any appearance of support for either Democrats or Republicans.
It noted the only states picked for the recount were ones Hillary Clinton lost.
"And this recount does not address the disenfranchisement of voters; it recounts votes that were already counted rather than restoring the suffrage of voters who were prevented from voting," the statement reads.
Stein's lawyers allege computer hackers could have changed the election outcome and that the state's heavy use of paperless machines makes it a prime target. Stein also contended that Pennsylvania erected unconstitutional barriers to voters seeking a recount.
In Pennsylvania, Trump got 2,955,671 votes for a 49,543-vote lead over Democratic nominee Hillary Clinton, who got 2,906,128 votes, according to the Department of State. Stein received 49,678 votes. or just 0.82 percent.
Stein was attempting to have a recount in two other states closely won by Trump over Democrat Hillary Clinton: Michigan and Wisconsin. A turnaround of two closes races -- Pennsylvania and Michigan -- would have given Clinton enough votes to claim the presidency instead of Trump, who claims 306 Electoral College votes. A total of 270 is needed.
Late Wednesday, a federal judge in Michigan stopped a recount of the state's presidential ballots just three days after it started on the grounds it is unnecessary. Trump got 2,279,543 votes in the state, compared to 2,268,839 for Clinton -- a difference of 10,704 votes. Stein had 51,463 votes, or 1.1 percent, according to the Michigan State Board of Canvassers. Michigan has 16 Electoral College votes.
The Wisconsin recount was finished Monday. Trump increased his lead by 131 votes as Clinton gained 713 votes over her previous total but Trump added 844. Stein's total stayed the same.
Trump earned 1,405,284 votes in the state for a 22,748 advantage over Clinton, who earned 1,382,536, and Stein, who had 31,006, or 1.04 percent, according to the Wisconsin Elections Commission. Wisconsin has 10 Electoral College votes.