Theresa May has refused to apologise for her “hostile environment” immigration policy, although she conceded that members of the Windrush generation had become wrongly entangled, sometimes at the cost of their own lives.

The prime minister said the policy was intended to identify illegal immigrants and said it would remain, even though thousands of people who were British citizens had their right to remain in the country and use healthcare, housing and other public services questioned.

“The policy, the purpose of the policy, it was to ensure – and we maintain a compliant environment policy – to ensure that those people who are here illegally are identified and appropriate action is taken,” May said in an interview on BBC One’s Andrew Marr Show.

“I apologise for the fact that some people, who should not have been caught up in that, were caught up in that – in some cases with tragic results.”

May had been asked whether she regretted the hostile environment policy she introduced as home secretary, which demanded that people submit paperwork to prove they were UK citizens to access public services.

The prime minister was shown video of Sarah O’Connor, a Windrush victim, who has since died aged 57, saying: “Apologies are all good and well, but an apology doesn’t help all the Windrush people have gone through.”

Commonwealth nationals living in the UK before 1973 were automatically granted citizenship without requiring a certification or other paperwork, but several thousand people discovered in recent years they were unable to prove their eligibility and were denied public services or, in some cases, deported.

May was asked if she knew how many people in the Windrush generation had been denied benefits, healthcare or lost their homes, but she would not supply the figures. “The Home Office has been looking at all the issues affecting the Windrush generation,” she told Marr.

Diane Abbott, the shadow home secretary, said May’s refusal to apologise for her hostile environment policy was disgusting. She added: “The Windrush scandal has exposed a moral failure at the heart of this rotten government. Lives have been destroyed. Theresa May should hang her head in shame.”