HARRISBURG, Pa. (AP) – A nearly 2-year-old requirement that almost all of Pennsylvania's 8.2 million voters must show photo identification before casting a ballot was struck down Friday by a state judge, setting the stage for a courtroom showdown before the state's highest court.

Commonwealth Court Judge Bernard L. McGinley, a Democrat, said the law would unreasonably burden the fundamental right to vote, and the state had been unable to convincingly explain why it was necessary.

"Voting laws are designed to assure a free and fair election; the Voter ID Law does not further this goal," McGinley wrote in his 103-page ruling.

It is not constitutional, he wrote, because it does not require that a valid photo ID be convenient and available to voters.

"As a constitutional prerequisite, any voter ID law must contain a mechanism for ensuring liberal access to compliant photo IDs so that the requirement ... does not disenfranchise valid voters," McGinley wrote.

The law, one of the strictest in the nation, was approved by the Republican-controlled Legislature and signed by GOP Gov. Tom Corbett in March 2012 over the protests of every single Democratic lawmaker.

Enforcement of the photo ID requirement had been blocked by earlier court orders pending resolution of the constitutional challenge. Both sides had vowed to appeal a negative decision to the Pennsylvania Supreme Court.

Friday's ruling did not strike down the entire law, but it prohibits enforcement of the photo ID requirement that is its central element.

At an unrelated appearance Friday morning, Corbett declined comment on the ruling. Lawyer Witold J. Walczak of the American Civil Liberties Union, which helped lead the legal challenge, said "the act was plainly revealed to be nothing more than a voter suppression tool."

Pennsylvania's Democratic leaders charged that the law was a cynical attempt by Republicans to hold down balloting by seniors, minorities and other Democratic-leaning groups in the last presidential election. Republicans called it an election-security measure, but administration officials acknowledged that they knew of no examples of voter impersonation,

The legislation was approved during a presidential election campaign at a time other GOP-led states also were tightening their voting requirements – setting off a partisan clash that continued through Election Day.

At a 12-day trial, plaintiffs including the National Association for the Advancement of Colored People, the Pennsylvania League of Women Voters and Philadelphia's Homeless Advocacy Project emphasized problems in processing and distributing a new voting-only ID card available for free to voters without a Pennsylvania driver's license or other acceptable ID. They said dozens of registered voters who applied for the cards before the 2012 election did not receive them until afterward.

Lawyers for the state defended the law, arguing that a multimillion-dollar publicity campaign in 2012 and the refinement of the special voting-only card by the Pennsylvania Department of State educated voters about the requirements of the law and would ensure that any registered voter who lacks an appropriate ID can now get one.

In his ruling, McGinley cited "overwhelming evidence" that hundreds of thousands of qualified voters lack IDs that comply with the law and panned the state's educational and marketing efforts as "largely ineffective and consistently confusing."

The judge also said distributing the special IDs through the state Department of Transportation's several dozen licensing centers was an inconvenience for voters.

"In contrast to 9,300 polling places, to obtain an ID for voting purposes, a qualified elector must overcome the barrier of transport and travel to one of PennDOT's 71 (licensing centers) during limited hours," he said.