LONDON — Anthony Bryan was watching the news in his studio apartment one morning in September 2016 when immigration authorities and police showed up with a battering ram.

“They were trying to beat down the house. I’m not a criminal or nothing. They were knocking the door and the window at the same time,” said the 60-year-old grandfather, who followed his mother from Jamaica to Britain in 1965 as part of a government-sanctioned migration movement to ease labor shortages and help rebuild the country.

Bryan said he spent five weeks in two separate detention centers in the past two years. Immigration officials booked him on a plane to Jamaica, until a lawyer intervened.

“To be honest, it wasn’t nice,” he said, demonstrating the British knack for understatement.

On Tuesday, Prime Minister Theresa May apologized to leaders of 12 Caribbean countries for the recent treatment of some members of the so-called Windrush generation — named after the first ship that brought the workers to Britain in 1948 — who have found their lives upended as British authorities crack down on who is eligible to live and work in the country.

“I want to dispel any impression that my government is, in some sense, clamping down on Commonwealth citizens, particularly those from the Caribbean,” she said. “We are genuinely sorry for any anxiety that has been caused.”

May is closely associated with the tightening of immigration rules. When she was home secretary in 2012, she boasted of creating “a really hostile environment for illegal immigrants.”

But, unlike the “dreamers” at the center of similar controversy in the United States, the Windrush families came to Britain legally, arriving from Commonwealth countries in the Caribbean. They were subjects of the crown, invited by the British government.

Oxford University’s Migration Observatory estimates that about 500,000 people born in Commonwealth countries moved to Britain before 1971, which marked the end of the right to free movement from across the Commonwealth.

The problem is that some of these people do not have the paperwork to prove they have a place in the only country they have known for decades.

They have been caught in bureaucratic limbo, struggling to meet the government’s demand for documentation — in some cases, up to four separate pieces of evidence for each year they have lived in Britain. People have lost jobs, been denied health services or received threats of deportation.

“These are my roots, this is where I live, I built my life here, not in the West Indies,” said Michael Braithwaite, 66, who moved to Britain in 1961. He worked as a special-needs assistant at an elementary school in north London for 15 years before he lost his job last year because he was unable to pull together all the necessary documents.

“It was devastating,” he said. “I thought I was in a dream, or a nightmare, really.”

The scandal has drawn widespread fury — uniting politicians and newspapers from across the political spectrum. A petition on Parliament’s website calling for amnesty for anyone who was a minor arriving in Britain between 1948 and 1971 received more than 150,000 signatures, surpassing the threshold for parliamentary debate. More than 140 lawmakers sent a letter to the prime minister demanding that the government find an “immediate and effective” response to the situation.

“This is an unmitigated disaster,” said Rob Ford, a politics expert at Manchester University. “It is also the logical and obvious consequence of immigration laws passed in 2014 and 2016, the main architect of which was . . . Theresa May.”

The measures backed by May as home secretary included requiring immigration status checks by doctors, teachers, landlords and employers.

Campaigners say these changes have resulted in discrimination.

“Let’s imagine you’re a landlord. You’re now asked to do the job of an immigration official,” said Satbir Singh, the chief executive of the Joint Council for the Welfare of Immigrants. “You can’t possibly ask everyone to demonstrate their immigration status to you, so what do you use as a proxy? Their skin color, their name, their accent, their ethnicity.”

The controversy has also stoked fears among the 3 million citizens of the European Union who live in Britain and wonder about their status next year after the country leaves the E.U.

“This will be deeply worrying for millions of E.U. citizens in the U.K. who will now fear similar treatment after Brexit,” Guy Verhofstadt, the European Parliament’s Brexit chief, told the Independent.

The 2016 Brexit vote was largely fueled by anti-immigrant ire and demands for tougher policies. Yet British authorities now must work out rules that recognize the country’s long tradition of welcoming newcomers from corners of the former British Empire.

On Monday, the government said that it would set up a task force dedicated to helping members of the Windrush generation formalize their immigration status.

Bryan said he lost his job in 2015 when he couldn’t produce the correct paperwork for his employers, who faced a fine of about $14,000 if they continued to employ him.

But he said that on his way into a television studio on Monday night, an immigration official suggested in passing that his biometric card was ready — establishing that he is in Britain legally.

He was elated. “I called my mom, my sister, I called everybody but God,” he said. “If I could have called God, I would have done so, too.”