Late in the afternoon on New Year’s Day, David MacMillan and a friend were food shopping in D.C. when the supermarket’s pharmacist approached. She was closing in 10 minutes and had two doses of unused coronavirus vaccine. Were they interested? If not, she would have to discard the precious liquid.

“It was random. I wasn’t expecting it. I wasn’t going to be eligible for the vaccine for months,” said MacMillan, a 31-year-old law student and employee at a law firm. “I figured July.”

Within minutes, MacMillan and his friend were inoculated, providing them a route out of the pandemic. MacMillan plans to head back to the pharmacy Jan. 29 for the second dose of a vaccine that studies show is better than 90 percent effective against the virus, which has killed more than 359,000 people in the United States, according to data compiled by The Washington Post.

“I feel like I’ve used up all my luck for the year on the first day,” MacMillan said. But “that’s one fewer person who can spread it to other people.”

No one expected a perfectly smooth rollout of two new vaccines to hundreds of millions of people, an endeavor that has been hindered by delays in its first few weeks. But the campaign also is bringing good fortune to a few lucky souls such as MacMillan, who find themselves serendipitously in the path of unused doses of the vaccine.

The two authorized vaccines, made by Moderna and Pfizer-BioNTech, must be used within six hours after being removed from subzero storage and reaching room temperature. Otherwise, they must be discarded.

The Pfizer medication is diluted before use, another factor that affects its window of usefulness. Moderna’s product comes in 10-dose vials, while Pfizer’s vaccine is contained in five-dose bottles.

With a disease-weary nation awaiting deliverance, the workers distributing vaccines are trying not to waste a single drop.

So when an overnight refrigeration failure in Ukiah, Calif., jeopardized 600 doses, officials there found themselves with two hours Monday to distribute the vaccine or lose those doses. The vaccine quickly went to jail guards, an elder-care facility, firefighters and others across Mendocino County.

Within 90 minutes, Ukiah fire chief Doug Hutchison said, more than 100 people in the city were vaccinated, including Hutchison and most of the fire department’s 16 members.

Though the firefighters are all paramedics, part of California’s top tier of vaccine recipients, Hutchison, 52, had expected to be immunized in late January. Fate moved him up about a month.

Hutchison said he feels some remorse over receiving the vaccine ahead of a few of his firefighters who were not available that day. But “it’s better that it got utilized, and then we can get it out to the community,” he said in an interview Wednesday.

At medical centers, where front-line health-care providers have been vaccinated since nurse Sandra Lindsay received the first shot Dec. 14, it’s difficult to avoid having a few extra doses at the end of each day. Caregivers occasionally miss appointments, or a few doses are left over from vials of five and 10, officials said.

With little guidance from the government, hospitals are working out their own policies. The Mayo Clinic system, headquartered in Rochester, Minn., offers extra doses first to workers in the emergency department and covid-19 units, according to Melanie D. Swift, co-leader of the health system’s vaccination plan. After that, vaccinators are offered a shot.

Running out of unvaccinated arms, Mayo is now “piloting a ‘last minute list’ where people who are scheduled for vaccination at a future date can sign up if they are available to be vaccinated during the last hour of the vaccination clinic,” Swift said in a statement.

A spokeswoman said the system administers about one to three doses per day this way.

At Yale New Haven Health, the system’s hospitals also keep “a list of those already signed up but who are flexible with appointment timing, so that if extra doses remain at any point or there is a no-show, one of those employees is notified and vaccinated,” spokeswoman Dana Marnane said in an email. To date, she said, 14,500 Yale health-care providers have been immunized.

The Food and Drug Administration’s formal policy remains to discard vaccine left over in vials, the agency said, with the Centers for Disease Control and Prevention determining who should receive vaccine. The CDC did not respond to a request for comment. Neither Pfizer nor Moderna has a policy on unused vaccine.

But Alex Azar, secretary of health and human services, urged officials Wednesday not to be hamstrung by federal priorities that call for health workers and residents and employees of elder-care facilities to be first in line.

“It’s more important to get people vaccinated than to perfectly march though each prioritized group,” Azar said at a briefing on the vaccination effort.

In MacMillan’s case, the pharmacist was following policy set by the District of Columbia, according to Felis Andrade, a spokesman for Giant Foods.

Some vaccine has been administered outside the bounds of intended policy. On Saturday, word got out that a health-care clinic in Austin was distributing vaccine and some people scrambled to get in line, according to the Austin American-Statesman.

One was Betsy Christian, who, according to the article, posted on Facebook: “OK, judge me. Daughter, spouse and I got the vaccine today. We have no underlying conditions, aren’t elderly and aren’t front-line workers.” She said the father of her daughter’s roommate had told them that the “extra vaccines” would “go bad if not used today.”

“We felt bad taking someone’s place but the vaccines would have gone to waste. Are we rationalizing?” she added, according to the article.

Those posts are no longer public, and Christian and her husband did not return telephone calls from The Post.

Heidi Shalev, a spokeswoman for Austin Regional Clinic, told the American-Statesman that once word got out, “there were so many people standing in line that we wanted to get everybody through and we wanted to use every vial of vaccine that we had. We wanted to make sure none went to waste. We did learn that a sign-up process in the future is something that we’ll do.”

MacMillan, who memorialized his vaccination on TikTok, said, “Maybe if there was more time, I would’ve said, ‘Isn’t there someone who needs this more than me?’ ”

But he said he had escaped his upbringing in a fundamentalist, anti-government, anti-vaccination community that later was the subject of a documentary, and he welcomed the opportunity to show that the vaccinations are safe. The side effects were mild, he said.

“Talk about a great way to start 2021!!” he wrote on TikTok.

Carolyn Y. Johnson contributed to this report.