Wisconsin residents without photo identification can vote in November’s election if they sign an affidavit swearing to their identity, a federal judge ruled Tuesday, providing temporary clarity in a long-running dispute about voter identification.

In granting the preliminary injunction, Judge Lynn S. Adelman of the Federal District Court in Milwaukee said a “safety net is needed for those voters who cannot obtain qualifying ID with reasonable effort.” He called the option of signing an affidavit “a sensible approach that will both prevent the disenfranchisement of some voters” but also “preserve Wisconsin’s interests in protecting the integrity of its elections.”

Wisconsin’s attorney general, Brad Schimel, said in a statement that he was “disappointed with the court’s decision.” Mr. Schimel’s office has defended the law for years and insisted that requiring identification was a necessary safeguard against voter fraud. The requirement was approved by Gov. Scott Walker and the Republican-led Legislature in 2011.

“We will decide the next course of action after Wisconsin Department of Justice attorneys have had time to fully review and analyze the court’s decision,” said Mr. Schimel, a Republican.