Joseph R. Biden Jr. on Wednesday afternoon won Michigan, a state in which his campaign invested heavily to secure a straightforward path to victory.
With about 97 percent of the vote counted, Mr. Biden was leading Trump by 49.8 percent to 48.6 percent.
Even before the Michigan race was called on Wednesday, the Trump campaign had announced that it was suing to halt the counting of mail-in ballots in the state because of what it called insufficient transparency in the process.
“President Trump’s campaign has not been provided with meaningful access to numerous counting locations to observe the opening of ballots and the counting process, as guaranteed by Michigan law,” said Bill Stepien, Mr. Trump’s campaign manager.
The victories in Michigan and Wisconsin for Mr. Biden further improved his prospects of reaching exactly 270 electoral votes and eking out a victory over Mr. Trump. But Mr. Biden would still need to nail down victories in Arizona and Nevada, where he is leading but where plenty of votes are yet to be counted. If he wins those two states, Mr. Biden does not need Pennsylvania, where he is trailing.
Michigan had been reliably blue in choosing a president for nearly 25 years, until 2016, when Mr. Trump won the state by the smallest margin in the country — 10,704 votes. But Mr. Biden saw consistent leads in virtually all major polls leading up to Election Day.
The Biden campaign viewed the working and middle-class moderate voters of the Midwest as Mr. Biden’s natural base, and it tried to build a coalition that was made up of more white voters than the base that elected former President Barack Obama and that Hillary Clinton tried to retain in 2016.
Four years ago, Michigan provided one of Mr. Trump’s most surprising victories and helped him take back the Northern industrial states that had favored Democrats in presidential elections since the 1990s. In this election, Mr. Trump’s popularity took a serious hit with the coalition of white voters — independents, those who had an unfavorable view of him but supported him anyway, people with and without college educations — that helped secure his win in Michigan in 2016.
A surge in new coronavirus cases and the rise of right-wing violence after a plot to kidnap Gov. Gretchen Whitmer, a Democrat, left Michigan voters rattled in recent weeks as they went to the polls. There have been at least 207,830 cases and 7,758 deaths in Michigan since the beginning of the pandemic, according to a New York Times database.