When Congress created a grant program early this year to help battered bars and restaurants survive the pandemic, one thing was immediately clear: The money would not be enough. The Restaurant Revitalization Fund contained $28.6 billion, far below the $100 billion that industry groups estimated was needed.

That made the rules about priority treatment — which were upended midstream by lawsuits from white male business owners who called them unfair — a crucial factor in determining who received relief.

But Small Business Administration records obtained by The New York Times reveal a capricious methodology for determining winners and losers. In the most extreme cases, applicants whom lawmakers intended to favor — women and business owners from certain racial and cultural groups — ended up effectively locked out. And even those unaffected by the litigation found themselves in a race for cash in which later applicants sometimes beat out those who had applied much earlier.

“So many of the people who needed this the most were left out,” said Matt Buskard, the owner of Bobcat Bonnie’s, a small chain in and around Detroit. Three of his locations had six-figure grants approved and then canceled a month later, after lawsuits threw the program into turmoil.

The restaurant fund, which the Small Business Administration ran, was intended to be a targeted program with more lucrative aid than earlier efforts, like the agency’s Paycheck Protection Program. It offered grants of up to $10 million to cover the shortfall between prepandemic revenue and 2020 sales, minus other relief payments — effectively making the restaurants whole for a lost year.

Heeding the wishes of President Biden, who pledged to put equity at the center of his agenda, lawmakers initially ordered the Small Business Administration to put a priority on applications from women, military veterans and certain racial and cultural groups. But a few weeks after the fund started making awards, court challenges put that to a halt. The agency was then supposed to start awarding grants “in the order in which applications are received.”

That wasn’t what happened.

James Hutton submitted his claim just one minute after the application system opened on May 3, seeking $2.4 million for his business, Players Sports Grill & Arcade in San Francisco. At the end of June, his grant was denied.

Rocky Aiyash applied on May 24 — the last day the program accepted applications — seeking $1.8 million for Pazzo’s, an Italian restaurant in Chicago’s financial district. His grant was approved.

And agency data received by The Times under a public records request showed other striking irregularities inside a program that approved 101,000 applications and turned away 177,000 other qualified businesses.

More than 60 percent of the program’s funding — $18 billion — went to businesses run by women, veterans and historically underserved groups, mostly during an initial 21-day exclusivity period. But after court challenges overturned that rule, the approval process went haywire.

Records reviewed by The Times show that hundreds of the 24,000 grants made after the May 26 rule change went to applicants who were supposed to have been bumped to the end of the line. During that same period, the agency canceled at least 3,000 already-approved awards, including Mr. Buskard’s.

More than 1,000 successful applicants filed their claims on or after May 19, the day after the agency said the fund had effectively run dry. (Those figures exclude applications from businesses with less than $50,000 in annual sales; a set-aside for tiny companies had cash left until the very end.)

Mr. Aiyash was one of the lucky latecomers. He and his business partners opened Pazzo’s in 1999 and kept it running through the Great Recession. The restaurant had up to 60 employees before the pandemic; some had worked there for two decades.

The pandemic forced Pazzo’s to close for sit-down dining for more than a year and mostly wiped out the office-worker lunch crowd it relied on. Two Paycheck Protection Program loans totaling $340,000 helped a bit, but Mr. Aiyash’s outlook was bleak: He didn’t apply to the Restaurant Revitalization Fund right away because the odds seemed impossibly long.

“I just didn’t believe it was real, to be honest,” he said.

But a friend who had received a grant persuaded him to at least fill out the paperwork, and Mr. Aiyash filed his application just hours before the program closed. The grant money showed up in his bank account a week later — a happy surprise that helped Pazzo’s avert a permanent shutdown.

“We would have been gone,” Mr. Aiyash said. “There’s not even a question about it.”

So how was Mr. Aiyash’s grant approved when more than 100,000 others who had filed earlier were denied?

The Small Business Administration declined to discuss individual applications. But a senior agency official, who spoke on the condition of anonymity because of the sensitivity of the matter, acknowledged that some late applications had zipped through the system. Myriad technical reasons affected their speed, the official said.

For example, claims for large sums faced more extensive vetting, and single-location restaurants were less complicated than chains seeking multiple grants for multiple spots, the official said. Perhaps most crucially for Pazzo’s, Mr. Aiyash applied using Toast, a restaurant sales software vendor that worked with the Small Business Administration to integrate its system, which significantly simplified the agency’s review.

The agency official compared the very late applications that got funding to a “perfect straight flush” — a wildly unlikely jackpot.

Which is precisely what grated on Mr. Hutton, who had applied the moment the fund opened.

“Government assistance shouldn’t be a lottery,” he said.

Mr. Hutton spent weeks studying the program’s rules and preparing his paperwork. He viewed the grant as life-or-death for his business, which began nearly 30 years ago with a bungee trampoline on Pier 39, a popular tourist spot, and eventually encompassed a tiki bar, an arcade and a restaurant.

For nearly four months, his company was fully shut down. Logistics made takeout impractical — the restaurant juts out over the water and is hundreds of feet from a road — and food was never Players’ main selling point, anyway. Visitors came for the drinks, the games and the panoramic view of Alcatraz Island.

The $1.1 million in Paycheck Protection Program loans that Mr. Hutton received made only a small dent in his losses, which reached six figures in some months on rent, insurance and other overhead. It wasn’t until May that the business fully reopened.

The Restaurant Revitalization Fund seemed like a chance at salvation. But after he applied, his application never budged. Mr. Hutton made more than a dozen calls to the program’s help hotline; each time, he said, he was told that he simply had to be patient.

The bad news arrived on June 30, almost two months after he applied. “Due to overwhelming demand, the S.B.A. was unable to fund all qualified applications,” an email informed him. “Those applicants who have not received funding as of this email will have their applications held within the application platform to allow for processing in the order received if additional funds are provided by Congress.”

Restaurateurs and their advocates are desperate for Congress to act.

Senator Chuck Schumer, the New York Democrat and majority leader, told applicants at forums early this year that the fund would be replenished as needed. On Twitter, he referred to the $28.6 billion allocation as “a down payment.” But a handful of attempts by members of both parties to refill the program have fizzled, and Congress has largely shut down for the year.

“Congress went home, and their neighborhood restaurants and bars are going out of business,” said Erika Polmar, executive director of the Independent Restaurant Coalition. “The nearly 200,000 restaurants that have applied for but have not yet received the R.R.F. told us they were out of time months ago.”

The rapid spread of the Omicron variant of the coronavirus has added to the urgency. Restaurants teetering on the brink aren’t sure they can survive another setback.

“Just this week, we had three big corporate holiday parties cancel,” said Catherine Manning, an owner of Villanelle, a farm-to-table restaurant in Manhattan.

Like Mr. Buskard, who has sued the Small Business Administration, Ms. Manning lost a six-figure award after the agency canceled thousands of undisbursed grants for those in the priority queue.

It was a crippling blow.

“If we’d had the funding, we could have proceeded with confidence and gotten through this winter,” Ms. Manning said. “But now, we’re going into the slow season, with Covid kicking up again. If we don’t get any help, I don’t know if we’ll be able to continue.”