McGinley also concluded that the multimillion-dollar education campaign the state designed to help voters obtain IDs only confused them.
"This is a devastating indictment of Pennsylvania's voter ID law," said Michael Rubin of the firm Arnold & Porter, which represented the plaintiffs.
The ruling was the latest twist in a battle that paralleled similar laws and challenges in other states. Supporters and critics have said they expect the case to end before the state Supreme Court.
Pennsylvania's law, one of the strictest in the nation, was signed by Gov. Corbett in March 2012 after heated legislative debate and public protests along partisan lines.
Republicans said it was designed to protect the election process from voter fraud, while Democrats said it would suppress the vote, particularly among minorities and the poor, who often support Democratic candidates.
Enforcement of the law had been blocked by court orders pending resolution of the constitutional challenge.
Both sides in the legal battle had vowed to appeal an unfavorable decision to the Pennsylvania Supreme Court. Speaking to reporters in Philadelphia on Friday, Gov. Corbett said he had not reviewed the ruling.
In a statement, his top lawyer, general counsel James D. Schultz, said: "We will continue to evaluate the opinion and will shortly determine whether posttrial motions are appropriate."
Attorney General Kathleen Kane, a Democrat whose office defended the law on behalf of the commonwealth, said she would await her client's decision.
Witold J. Walczak, attorney for the American Civil Liberties Union, which helped lead the legal challenge, said that under the decision, "the act was plainly revealed to be nothing more than a voter-suppression tool."
The opinion also sparked criticism. Rep. Daryl Metcalfe (R., Butler), who authored the voter ID legislation, assailed McGinley, a Democrat, for what he described as a political ruling.
"In a partisan manner, he struck down a law that should have been held constitutional," said Metcalfe. "He's pretty much taking, hook, line, and sinker, the Democratic position."
The case has bounced back and forth through state courts for two years. Under a preliminary injunction, the state had required poll workers to ask for, but not demand, IDs before voters cast ballots.
During a 12-day trial last summer, the plaintiffs called dozens of witnesses that they said represented the hundreds of thousands of voters lacking acceptable IDs. They argued that the difficulty of getting one might discourage some people from voting.
State officials had defended the law as necessary to prevent fraud, while conceding there was no evidence of in-person voter fraud.
They maintained that voters had ample opportunities to get a valid ID, at one point creating a special Department of State ID - 17,800 have been issued - for voters lacking the proper documents for a standard driver's license or nondriver's identification.
The lead plaintiff in the case, 94-year-old Viviette Applewhite of Philadelphia, said Friday that she did not believe the case would end with the judge's ruling.
"I'm tired of going up there to Harrisburg," she said. "But I'm going to go with it until it's all over with."
Applewhite was able to obtain a PennDot voter ID in August 2012, even though she lacked the required documents - a discrepancy that lawyers said showed that the state's policies had been applied inconsistently.
The administration has spent about $6 million in state and federal funds for voter education about the law and $1 million in state funds to the Philadelphia law firm Drinker Biddle to help defend it.
One critic of the law, Senate Minority Leader Jay Costa (D., Allegheny), assailed the administration as wasting money on a bad law and urged the governor to drop the case.
"The administration has spent millions implementing and trying to defend a law whose only purpose was to disenfranchise hundreds of thousands of voters," he said. "They shouldn't spend another penny defending it."
Inquirer staff writers Kristen A. Graham, Angela Couloumbis, and Jessica Parks contributed to this article.