They came from Colombia and Chad, from Burundi, Peru, Venezuela, Madagascar. In New York they had heard there was a haven for immigrants, a place to live and get back on their feet.

When they arrived, they found out that they had heard wrong.

Two, three, four days later, they were still lined up outside the city’s migrant intake center at the Roosevelt Hotel, around the corner from Grand Central Terminal — close to 200 people, nearly all men. Sleeping on the sidewalk. Heads resting on book bags, trash bags of belongings by their sides: the visible faces of a system that has officially broken down.

For over a year, record numbers of asylum seekers have arrived in New York from across the globe, nearly doubling the city’s homeless population in one huge spasm: More than 100,000 people now live in shelters in the city.

Unlike other American cities, especially in the West, where thousands live in the streets for lack of other options, New York City is legally required to give anyone shelter who asks for it.

But now the shelters are full. As the migrants have continued to arrive, the city has built tents, cobbled together a vast portfolio of hotels and office buildings turned into housing and given migrants tickets to go elsewhere. It has not been enough. The mayor has called for state and federal help, saying the city is overwhelmed. And officials have also, increasingly, pushed back against the city’s legal obligations to shelter homeless people.

Mohammadou Sidiya, 20, from Mauritania in West Africa, stood beside a friend on Tuesday morning. They had traveled for more than a month to get here.

They came looking for safety, Mr. Sidiya said in Arabic, through a digital translation. They failed, he added.

Twenty feet away, a cheerful sign taunted them. “Bienvenidos al arrival center!” it read. “We are currently at capacity.”

New York City’s descent from a place that was managing to keep up, just barely, with a ceaseless flow of asylum seekers to a place that had declared defeat was sudden.

Last week, there were still enough beds to allow the city to honor its legal obligation to offer shelter to every person who wanted it.

Sometime over the weekend, that stopped being the case.

No explanation was offered. Mayor Eric Adams simply said on Monday, “There is no more room.” He also said, “From this moment on, it’s downhill.”

Josh Goldfein, a staff lawyer at the Legal Aid Society, which filed the litigation that led to the right to shelter more than 40 years ago, said he believed that the people sleeping outside the Roosevelt were there in part because the mayor was trying to pressure Washington to send more aid and trying to discourage more migrants from coming.

“There are many ways the city could shelter everyone who is on that sidewalk if that is what they wanted to do,” he said.

Fabien Levy, a spokesman for the mayor, said on Tuesday that the 194 locations the city has opened to shelter asylum seekers are at capacity.

“Our teams run out of space every single day, and we do our best to offer placements where we have space available,” he said. He added that the city is adding two more big humanitarian relief centers in the coming weeks, including a mega-tent big enough for 1,000 people in the parking lot of a state psychiatric hospital in Queens. The city has estimated that the migrants will cost more than $4 billion over two years.

Mr. Levy said that Sunday was the first night that the Roosevelt was unable to offer all migrants a place to stay indoors, even if on a chair. He said that on other nights, some had been sent to another hotel where they could stay on a cot, and that any migrants who slept on the sidewalk did so by choice. He also noted that migrants had access to air-conditioned buses.

Behind Mr. Sidiya in the line was Erick Marcano, a laborer from Venezuela. He said he had taken his place on the line on Saturday and in the ensuing three days had progressed a total of one block, from the corner of 46th Street to the corner of 45th. He had used the time to fashion an effective sun hat by jamming a piece of a cardboard box with a skull-shaped hole cut into it onto the brim of his baseball cap.

Mr. Marcano had crossed the border a few days before that and received help from an immigrant advocacy group. “They asked us in Texas where we wanted to go in the U.S. and that they would pay for the ticket, and we told them we wanted to come here, to New York,” he said.

Outside the Roosevelt, he said, “they just tell me to have patience and wait.” Down the block, at the entrance to the hotel, families with young children flowed in and out. The city has prioritized providing shelter to them, so that only adults are left outside.

Gov. Greg Abbott of Texas, a Republican, has chartered some of the buses that have brought people to New York City, as a way to put political pressure on Democratic leaders, though the vast majority of migrants have come in other ways.

On Tuesday, the Legal Aid Society threatened to take the city back to court. Mr. Goldfein said that Gov. Kathy Hochul also needed to do more to provide resources and aid to get people housed quickly.

“We are hopeful that the state will step up and meet its obligations and also that the city will make some changes to what they’re doing in order to get people off the street,” he said, “but if they don’t, then we will have to take any appropriate action to protect our clients.”

A 30-year-old migrant from Chad who gave only his first name, Abdelkerim, said he was surprised to find himself forced to sleep on the street in New York. “I’d at least think we’d have a place to stay,” he said.

The migrants have been provided with food while they wait. On Tuesday, workers with carts went down the line handing out egg sandwiches, bottled water, bananas and popcorn. Just past the end of the line was Uncle Paul’s pizzeria. The owner, Dino Redzic, said that he had given out 10 pizzas the night before and was letting the migrants use his bathroom. “They stay there half an hour and they wash themselves,” he said.

Mr. Redzic, 50, himself a refugee from the Bosnian war who came here 30 years ago, said he was disturbed by the scene unfolding beside his store. “Why is this happening?” he said. “Where are the churches? Where are the mosques? Where are the people supposed to take care of them?”

As the afternoon wore on, Ariana Diaz, 34, freshly arrived from Venezuela via Baja California, took her place at the back of the line. She had paid for her own plane ticket from the West Coast, counting on a warmer welcome here.

Where would she stay tonight, Ms. Diaz was asked.

“I don’t even know where I’m standing right now,” she said.

Wesley Parnell and Olivia Bensimon contributed reporting.