US president Barack Obama has castigated American companies for “gaming the system” by relocating their headquarters to countries such as Ireland where corporate tax rates are lower to avoid taxes in the US.

In his administration’s most high-profile attack on a practice known as “inversions” that more and more US companies have recently used to reduce their taxes, Mr Obama said in a speech in California that US corporations were exploiting an “unpatriotic tax loophole” by moving their head offices overseas in takeovers of smaller foreign companies.

The president, in an interview broadcast later on the business news TV network CNBC, named Ireland as a location that US companies are using to take advantage of “technically legal” tax arrangements.

“What we are trying to do is to say that if you simply acquire a small company in Ireland or some other country to take advantage of the low tax rate [and] you start saying, ‘we are now magically an Irish company’, despite the fact that you might have only 100 employees there and you have got 10,000 employees in the United States, you are just gaming the system,” he said. “You are an American company.”

In his speech at a Los Angeles college, he said that these companies were technically renouncing their US citizenship, even though most of their operations were in the US.

“I don’t care if it’s legal – it’s wrong,” he told an audience. “You don’t get to choose the tax rate you pay. These companies shouldn’t either.”

In an extraordinarily strong rebuke of US multinationals, he said some have called these firms “corporate deserters”.

“You shouldn’t get to call yourself an American company only when you want a handout from American taxpayers,” he said.

Ireland is one of the more popular countries for US companies seeking foreign acquisitions in recent years because of the Irish corporation tax rate of 12.5 per cent, which is about a third of the US rate of 35 per cent, one of the highest in the developed world.

Republicans and Democrats are divided over how to stop the practiceas the rate of takeovers has recently accelerated and may extend from the healthcare sector to US high-street retailers.

The White House has supported Democratic efforts in Congress to pass a law curbing inversions but Republicans oppose this, preferring changes as part of a broader reform of the US tax system that would lower the corporation tax rate to make it more competitive.