Medical device maker Medtronic PLC found itself in an enviable position in March when one of its executives joined a U.S. trade mission to Peru, where there is a booming health-care market. The trip included “matchmaking” meetings with Peruvian businesses and networking luncheons with the Lima Chamber of Commerce.

The delegation of more than a dozen health-care companies also visited a new $75 million hospital serving 600,000 people in Villa El Salvador, a sprawling shantytown on the outskirts of Lima. There, Medtronic received an influential shout-out. “Toured new state of the art hospital … Mission member @Medtronic provided their tech,” Bruce Andrews, the deputy secretary of Commerce leading the trip, said in a Twitter post.

In promoting the three-day trip, the Commerce Department had promised opportunities for “U.S. companies … to expand their footprint” in the country, and Medtronic was now a featured player.

Except by the time the trip took place, Medtronic, a behemoth that started humbly in a Minnesota garage in 1949, had claimed Ireland as its corporate home and given up its U.S. citizenship.

In doing so, Medtronic joined a parade of prominent U.S. companies that have set up operations overseas to lower their tax bills. The migration has grown so large it is attracting scrutiny from tax collectors on both sides of the Atlantic. In late August, the European Union ruled that Apple must pay $14.5 billion in uncollected taxes to Ireland, and regulators there are investigating tax arrangements involving McDonald’s and Amazon.

The maneuver used by Medtronic — an “inversion” — has attracted particularly harsh criticism and is expected to be the centerpiece of a contentious fight over reform of the corporate tax code next year. It is also a presidential campaign issue. Republican presidential nominee Donald Trump wants to lower the U.S. corporate tax rate, while Democrat Hillary Clinton would subject companies that move their headquarters overseas to an “exit tax.”

Medtronic shifted its official headquarters to Ireland after acquiring Dublin-based rival Covidien for $50 billion in January 2015. Irish corporations are taxed at about a third of the rate of U.S. companies — 12.5 percent, instead of 35 percent — and the move allows Medtronic to spend more of its overseas profit without paying U.S. taxes on it.

The move, lambasted by critics as unpatriotic, has saved Medtronic more than $3 billion in taxes and helped the company fund an acquisition spree as it emerged as the world’s largest medical device maker, overtaking Johnson & Johnson in that market. By moving its headquarters, which did not require company executives to decamp from their offices in Fridley outside Minneapolis, the firm has turned a corner that it says will help it compete in the rapidly evolving health-care market.

What Medtronic hasn’t done is give up many perks of being a U.S. company. In addition to attending U.S. trade missions, which can help it find customers, Medtronic still holds dozens of government contracts. Since its inversion, it has been awarded more than $40 million in contracts, according to federal procurement data.

“We should be, shareholders should be, angry that Medtronic has access to as much of the benefits of U.S. citizenship as they do,” said Matt Gardner, executive director of the Institute on Taxation and Economic Policy, a nonpartisan think tank.

The Commerce Department and Medtronic both said that no rules bar foreign-owned companies from participating in trade missions. Medtronic, noting that it still has about 43,000 employees in the United States, says it is typically invited on such trips. The company has hired an additional 1,300 U.S. workers since the merger was announced and has deep relationships with suppliers across the country, company spokesman Fernando Vivanco said. The company’s participation has a direct benefit to the United States, he added.

“We are not aware of any policies that restrict foreign-owned companies from participating in this activity,” Vivanco said. “Nor do we believe there should be as it will limit the impact of the U.S. government to meet its objectives of growing the U.S. market.”

During a White House briefing in April, President Obama took note of the duplicity of companies moving their headquarters overseas but continuing to operate as an American company.

These companies “effectively renounce their citizenship,” Obama said. “They declare that they’re based somewhere else, thereby getting all the rewards of being an American company without fulfilling the responsibilities to pay their taxes the way everyone else is supposed to pay them.”

But breaking the bond between a company and the U.S. government can be difficult.

Aon, a professional services firm, announced in January 2012 that it would move its headquarters from Chicago to London. The move, though not an inversion, has helped the company push its effective tax rate below 20 percent.

Still, later that year, the U.S. ambassador to Romania held a reception to celebrate the company’s success in that market. “Our Romanian office rented an event space in the U.S. Embassy — a common practice — and paid to do so,” a company spokesman said.

The Obama administration has repeatedly adopted rules intended to make inversions less appealing, but the government’s response has become more muddled as European authorities launch their own investigations.

In 2013, for instance, Tim Cook, Apple’s chief executive, was called before a Senate panel to explain the tech giant’s tax strategies. A Senate investigation had concluded that Apple used a “complex web” of offshore entities to shield at least $74 billion in profits from U.S. tax laws between 2009 and 2012. The company had a special arrangement with Irish authorities to pay little to no taxes on profit housed in its subsidiaries, the report found.

But when European authorities ruled recently that the tech giant owed $14.5 billion in back taxes after using phantom “home offices” in Ireland to push its tax rate to less than 1 percent some years, lawmakers jumped to Apple’s defense.

“This is a cheap money grab by the European Commission, targeting U.S. businesses and the U.S. tax base,” Sen. Charles Schumer, D-N.Y., said.

Even executives have a mixed response. Just a month before Medtronic announced its deal to merge with Covidien, Medtronic’s former chief executive, Bill George, penned a scathing op-ed criticizing pharmaceutical giant Pfizer’s plan to merge with AstraZeneca and move its headquarters to England.

“Is the role of leading large pharmaceutical companies to discover lifesaving drugs or to make money for shareholders through financial engineering?” George said in the New York Times in May 2014. “Does anyone believe pharmaceutical companies can create long-term shareholder value by chasing lower tax venues and cutting research and development spending?” (The acquisition fell through.)

But when Medtronic announced its merger, George struck a softer note.

George said in an interview that he quizzed Medtronic executives about the motivations behind the acquisition of Covidien and was ultimately convinced that it made sense strategically - and not just financially. While Medtronic specialized in medical devices that could be implanted in the body, Covidien had a strong business in the equipment used during surgery.

“It wasn’t like [Medtronic was] going to Bermuda; it was a real place,” he said. “They love Ireland, I know that,” noting that Medtronic already had employees there.

Founded more than 60 years ago as a medical equipment repair shop, the firm’s first breakout technology was a wearable, battery-powered cardiac pacemaker. It now sells thousands of pieces of medical devices, from ventilators to intubation tubes, across the world.

But by the time it began to consider acquiring Covidien in 2014, the medical device industry was under pressure. The hospitals that bought the bulk of the industry’s equipment were demanding lower prices. Several manufacturers looked to consolidate, hoping that by being bigger, they would be able to negotiate better deals for themselves, industry analysts say.

“They saw the writing on the wall - that the medical device industry needed to become more realistic about the future,” said Joshua Jennings, a physician who is now an analyst who covers the industry for the Cowen Group.

Acquiring Covidien made sense, company executives decided. And there was a bonus. Covidien traced its roots to 1903 and a small textile mill in Massachusetts but had been based in Ireland since 2007.

For years, Medtronic has been sitting on billions in foreign profits. By 2014, the stockpile had reached $14 billion, but bringing it back to the United States would mean paying a 35 percent tax on it.

The company was eager to access some of that “trapped” cash.

“We were struggling with how to get cash back to the shareholders, acquisitions were harder,” said Gary Ellis, Medtronic’s executive vice president of global operations.

The deal immediately drew criticism from skeptics, who said the company was abandoning its roots. Congress and regulators rushed into action, and so did Medtronic.

The firm spent a record $5.3 million on its lobbying efforts in 2014, according to Opensecrets.org, including hiring former Sens. Trent Lott and John Breaux to help defend it against anti-inversion legislation introduced in Congress. It also promised to invest $10 billion over 10 years in the United States if the deal went through, helping garner some support. For Minnesota it promised to add 1,000 jobs over five years.

The deal closed about eight months after it was announced.

Not everyone was happy. Many long-term shareholders were hit with a capital gains tax as part of the inversion.

Among them was Donald Zibell, 78, who has owned Medtronic shares for more than 20 years, and paid a $135,000 capital gains tax on his 12,000 shares. Most of that has been recouped through the stock’s recent appreciation but that is still not enough for Zibell, a retired attorney.

“I think it was unfair to the shareholders,” he said.

For Medtronic, the inversion has proven transformative. The merged company was able to put to use nearly $10 billion in overseas profit. Instead of paying a 35 percent tax on those funds — more than $3 billion — it paid 5 percent, or $500 million.

Now an Irish company, Medtronic spent more than $1 billion to buy 14 companies in 2015. The company also spent about $5 billion buying back shares of its stock — which helped boost its share price — and increased its dividend to shareholders.

Medtronic says the deal has given it new financial flexibility. Before the merger, 60 percent of its “cash flow” — the money moving in and out of the company — could not be accessed without paying the U.S. tax. Now that is down to 40 percent, company executives say.

“As frustrating as it is,” Ellis said, “the reality is that the inversion structure was important for us to be able to actually invest more in the U.S.”