An Ohio law that curtails early voting and prevents people from registering to vote and casting ballots on the same day illegally discriminates against black voters, a federal judge ruled on Tuesday, ordering a crucial swing state to change its rules before the fall elections.

Democrats had challenged the law, describing it as one in a long series that Republicans in several states had enacted to suppress voting by blacks and Hispanics, who are more likely than others to vote early and to vote Democratic. Republicans denied that charge, saying the law combated voter fraud. Judge Michael H. Watson, of Federal District Court in Cincinnati, wrote in his findings that voter fraud was very rare and that the law did nothing to prevent it.

It is unclear what effect the ruling will have on turnout. Republicans would not say immediately whether they would appeal, but they noted that even with the provision the judge struck down, Ohio had one of the longest early voting periods in the United States, starting four weeks before an election.

Early voting in Ohio grew out of the 2004 election, when people stood in line for hours to cast ballots, particularly in heavily minority and Democratic urban areas. Thousands went home without voting. George W. Bush carried the state by 2.1 percentage points. If he had lost it, John Kerry would have become president.