Voters in Kentucky were on track to cast ballots in record numbers for Tuesday’s primary despite the risk of coronavirus infection and shortages of poll workers, thanks in part to the widespread embrace of voting by mail.

Michael G. Adams, Kentucky’s Republican secretary of state, projected that total turnout would exceed 1 million, including roughly 800,000 mailed ballots. The final figure would shatter the previous record of 922,456 primary voters set in 2008.

Poll worker cancellations had forced election officials to staff fewer than 200 polling locations instead of the usual 3,700, but Adams said an avalanche of mail-in balloting and in-person early voting helped lessen demand on the polls Tuesday.

The numbers reflected an overwhelming shift to absentee voting by Kentucky voters, even as President Trump has railed against mail ballots and claimed without evidence they lead to massive fraud.

As of mid-afternoon, about 570,000 absentee ballots had been received by election offices in the state, in addition to the 100,000 ballots cast at early voting locations. At least 156,000 people voted in person on Election Day.

Primaries were also held Tuesday in Virginia, as well as New York, where there were scattered reports of delays in opening polling sites, voters receiving incomplete ballot packages and long lines that stretched into the night.

In Kentucky, officials had been anticipating a high turnout in part because of a late surge by Senate candidate Charles Booker, a first-term state lawmaker who is challenging former Marine fighter pilot Amy McGrath for the Democratic nomination to take on Senate Majority Leader Mitch McConnell (R-Ky.) in November.

By the time polls closed in most of the state at 6 p.m. Eastern time, hundreds were still waiting in line to cast their ballots in Lexington, and were allowed to continue filing into a polling site at the University of Kentucky football field.

In Louisville, dozens of voters outside the Kentucky Exposition Center, the city’s sole voting location, were temporarily locked out when the polls closed at 6 p.m. Videos circulated on social media of people gathered outside the doors, knocking and asking to be let in.

Nore Ghibaudy, a spokesman for Jefferson County Clerk’s Office, said that everyone who was present and wanted to vote at 6 p.m. had been ushered into line before the doors were secured.

Both the Booker and McGrath campaigns filed petitions with the court seeking an extension of voting hours. Shortly after the doors were locked, a judge issued an injunction ordering election officials to keep the site open until 6:30 p.m., triggering a rush of people into the building.

Earlier this year, Adams joined with Kentucky Gov. Andy Beshear (D) to prepare for the primary, backing a bipartisan agreement to relax the rules of who could vote absentee because of the pandemic, allowing anyone to choose that method of casting a ballot.

On Tuesday, county officials opened a single voting location in both Louisville and Lexington — but did so in cavernous facilities with the capacity to process dozens of voters at a time. The two cities have a combined total of about 860,000 registered voters.

For most of the day, voting progressed smoothly at the Exposition Center in Louisville, while Lexington saw moderately long lines at Kroger Field.

Willie Richard, 59, said voting in Louisville was “a breeze, better than ever” — and actually quicker than his usual precinct.

Despite waits of up to 90 minutes in the blazing late-afternoon sun in Lexington, the atmosphere was largely convivial, with voters snapping photos and sharing pizza and water in line.

The delay was of no consequence to Teresa Clayborne, a local entrepreneur who said she was inspired by recent protests — and by her ancestors — to stand in the line for as long as it took.

“They died for this opportunity,” said Clayborne, who is African American. “And I’m going to take this opportunity. I don’t care how long it takes.”

After check-in lines grew in Lexington, the state elections board held an emergency meeting, where the state’s top elections official reported that additional check-in stations had been added and the lines had begun to ease.

“We got a little bit more voters than we expected, so the facility is running at about its maximum capacity,” said Don Blevins Jr., the Fayette County clerk.

Ghibaudy said Jefferson County made vastly different preparations than usual to address the pandemic. Workers set up more than 350 voting stalls, with more in the wings if needed. And they directed voters into 18 separate lines representing different precincts, each able to accommodate up to 30 socially distanced voters, he said.

Ghibaudy said the challenges in Georgia and other states that have recently held primaries provided a road map for what to do better on Election Day, although he said processing a wave of mail ballots added its own challenges.

“Last spring, we had 1,200 people request a ballot by mail,” he said. “Compared to 218,000 [this year]. That’s a lot . . . Of course, we only found out this is what we’d be doing five weeks ago.”

Kristen Clarke, who leads the Lawyers’ Committee for Civil Rights Under Law, a voting rights advocacy group, commended state and county officials for working across the aisle to find solutions for voters ahead of the primaries.

“Jefferson County officials certainly did a good job finding a site in the county that recognizes that there is a pandemic,” she said Tuesday during a media briefing. “This is a big space that allows for election officials to comply with social distancing requirements, allows for space between voters, and is ideal in that respect.”

But she said voters should have more than one in-person voting option on Election Day, noting the challenges people faced trying to cast their ballots in recent primaries in Georgia and Wisconsin.

More complaints arose in New York, where voters and advocates said polling locations opened late in Brooklyn and the Bronx. Polls closed at 9 p.m., with long lines remaining in several areas, including Yonkers.

Clarke said her organization received multiple reports of some New York sites opening as late as 2 1/2 hours after 6 a.m.

At the City Island School polling site in the Bronx, dozens of voters who were waiting in line left before the polling site eventually opened up at 8:49 a.m., Clarke said.

One of the main reasons for the delay in New York: The subway system was shut down until 5 a.m. for sanitizing, and poll workers did not have transportation to take them to their polling sites, she said. Even after one poll worker arrived, they had to wait for others to be able to open up the sites and get them running, she said.

“Poll workers unable to get to their poll sites on time was a huge problem this morning,” she said, calling the situation “incredibly unfortunate.”

In the East Bronx, many voters who filed into Harry S. Truman High School were directed to another site after poll workers said they had come to the wrong location.

Debra Murphy, who has lived for 25 years in nearby Co-op City, the country’s largest cooperative housing development, expressed frustration with the last-minute changes.

“I’m having a hard time breathing now,” said the 65-year-old, seated on her red medical scooter. “They need to be direct with us about where to go. We shouldn’t have to be walking around.”

Later, 21-year-old Dacia Sue walked out after voting with her 22-year-old fiance. The couple, who also live in Co-op City, were casting ballots for the first time and brought their young daughter, who sported a “future voter” sticker.

In normal circumstances, Sue said she would not have had time to vote because of her job in the food industry.

“It’s different now. We have time now,” she said.

About 1.7 million people requested absentee ballots for the primary, among New York’s 13 million registered voters, the state board of elections said Monday. That’s compared with fewer than 160,000 ahead of the 2016 primaries.

As of the end of last week, an estimated 30,000 voters in New York City had not received their mail ballots.

Frustrated city voters became so vocal on Twitter that the local board of elections began delivering individual updates via direct message on the status of ballots on Monday and Tuesday.

Trepidation about how pandemic-era voting would play out in Kentucky and New York came on the heels of troubled primaries in Wisconsin, Pennsylvania, Georgia and Nevada, where some voters waited in line for as long as five hours.

In Louisville, county clerk workers were overwhelmed by the lack of staff and the increased workload in the run-up to Tuesday, officials said.

During a normal election, Jefferson County employs 2,400 election officers. But on Tuesday, about 160 to 180 election officers were on duty, because of a shortage of people wanting to work during the pandemic, Ghibaudy said. Many of the trained poll workers are older and are in the vulnerable population, he said.

County clerk employees worked 12 to 18 hours a day in the week leading up to the election, Ghibaudy said.

Adding to the burden: County clerks are also responsible for recording vehicle titles and mortgages, and the workload is up in both those categories, with people using their stimulus checks to buy new cars or taking advantage of low interest rates to refinance their homes.

“It’s the perfect storm of busy,” Blevins said. “All of my automobile staff, the day we made the decision to do vote-by-mail, became election staff as well.”

In New York, counties were permitted to mail an absentee ballot application to every eligible voter. Elections officials in that state, which has a handful of competitive congressional primaries with liberal challengers to House Democratic incumbents, will not begin tabulating absentee ballots until one week after Election Day.

Likewise, officials in Kentucky, where ballots must be postmarked by Tuesday and received by June 27, said election results may not be known for a week.

Josh Wood in Louisville, Joe DePaolo in Lexington and Kayla Ruble in New York contributed to this report.

Correction: An earlier version of this article said that voters could cite the “medical emergency” excuse to vote absentee in Kentucky’s primary on Tuesday. In fact, voters did not need to cite an excuse to cast an absentee ballot.