Major US technology firms, including Apple, Microsoft and Facebook, are lining up to attack Trump’s government for its decision to end a programme protecting almost a million young migrants from deportation.

Microsoft has promised to go to court to defend any employee who faces deportation once the Deferred Action for Childhood Arrivals programme ends in six months’ time. If the government tries to deport a Microsoft employee, the company’s president, Brad Smith, said: “It’s going to have to go through us to get that person.”

Smith later clarified what that will mean in practice: “If Congress fails to act, our company will exercise its legal rights properly to help protect our employees. If the government seeks to deport any one of them, we will provide and pay for their legal counsel. We will also file an amicus brief and explore whether we can directly intervene in any such case.”

Apple’s chief executive, Tim Cook, tweeted support for those facing an uncertain future, saying that “Apple will fight for them to be treated as equals.” In an internal email, obtained by the Guardian, Cook went further, calling the move a “setback for our nation”. More than 250 Apple employees are protected by the programme, he said, and many of them have been writing to the company’s leadership asking for action to help the so-called Dreamers.

“I’ve received several notes over the weekend from Dreamers within Apple,” Cook wrote to employees. “Some told me they came to the US as young as two years old, while others recounted they don’t even remember a time they were not in this country.”

Cook wrote: “I want to assure you that Apple will work with members of Congress from both parties to advocate for a legislative solution that provides permanent protections for all the Dreamers in our country. We are also working closely with each of our co-workers to provide them and their families the support they need, including the advice of immigration experts.”

Facebook’s Mark Zuckerberg was similarly outspoken, calling the news “a sad day for our country.”

“The decision to end Daca is not just wrong,” he wrote. “It is particularly cruel to offer young people the American dream, encourage them to come out of the shadows and trust our government, and then punish them for it.”

Zuckerberg encouraged Facebook users to call their members of Congress and campaign for legislation that would give those affected by the decision a path to citizenship.