On either side of a two-lane road and surrounded by the lush green mountains of Villalba in central Puerto Rico stand a pair of manufacturing plants owned by Medtronic Inc., the world's biggest maker of heart rhythm devices.

Medtronic does more than half of its $16 billion in annual sales of pacemakers, defibrillators and other devices in the United States. It manufactures the equipment at this facility, legacy of a defunct U.S. tax break designed to encourage investment on the poverty-stricken island. Yet, Medtronic credits the income to a mailbox at an office in the Cayman Islands.

This isn't what Congress had in mind when it eliminated the federal tax credit for companies' Puerto Rican profits. The break was attacked by Republicans and Democrats as too expensive and was ended in 2006. So Medtronic and other companies found a solution: They are avoiding taxes by moving those profits into shell subsidiaries in havens such as the Cayman Islands, Switzerland and the Netherlands.

"By aggressively shifting income to offshore affiliates, companies appear to be getting U.S. tax benefits that are equal to or greater than the ones they did under the old Puerto Rico tax break," said Stephen E. Shay, former deputy assistant secretary for international tax affairs at the U.S. Treasury Department and now a professor at Harvard Law School. "That almost certainly was not the intent of the repeal."

The profits that used to benefit from the Puerto Rico credit are part of a mountain of tax-deferred offshore earnings totaling at least $1.38 trillion, according to J.P. Morgan Chase & Co. Several major U.S. companies, including Apple, Google, Microsoft and Pfizer, are lobbying Congress for a tax holiday to bring those profits home. Without a break, any cash brought back to the United States would be taxed at the federal income-tax rate of 35 percent, with a credit for foreign income taxes already paid.

Medtronic, based in Fridley, paid income taxes in fiscal 2011 at a rate of less than half that -- 16.8 percent. That's also about half Medtronic's rate under the old Puerto Rican tax credit.

As the Obama administration and congressional Democrats take aim at tax breaks for everything from corporate jets to private-equity manager pay, the aftermath of the Puerto Rico credit's repeal shows just how difficult ending such breaks can be.

In a memo sent to IRS auditors in February 2007, the IRS called profit levels "extraordinary" in many of the offshore units created to take over for the subsidiaries that got the Puerto Rican break. In many cases, those units are generating "an inordinate amount of the profits, i.e., amounts in excess of what would be expected, based upon activity," according to an IRS memo.

Tied up in court

The IRS is in a $958 million fight with Medtronic in U.S. Tax Court over how the company reorganized its Puerto Rican operations, as well as a $452 million court dispute with Arden Hills-based Guidant, now a part of medical device maker Boston Scientific Corp., over a similar move.

Companies legally move profits offshore using "transfer pricing," the system of allocating income between units in different countries. This lets corporations like Medtronic say that profit from a $5,000 pacemaker was earned in the Cayman Islands, even though the device was made in Puerto Rico and sold in, say, Houston. The company has accumulated $14.9 billion in income allocated to its foreign subsidiaries on which it hasn't paid any U.S. income tax, according to its most recent annual report.

The profit shifting that can stem from transfer pricing costs the U.S. government an estimated $90 billion a year, according to Kimberly Clausing, an economics professor at Reed College in Portland, Ore. That's about double the Department of Homeland Security's annual budget.

Under U.S. transfer-pricing rules, offshore subsidiaries that license rights from their parent companies are supposed to pay an "arm's-length" price, or what an unrelated company would pay. Such transactions often involve the transfer of intellectual property rights and other so-called intangibles, for which real world comparisons can be difficult to find. The IRS objects when offshore subsidiaries pay their parent company a price that the agency claims is too low, which shifts taxable profit out of the country.

"We are confident that Medtronic has met the requirement in establishing arm's-length pricing on all intercompany transactions," said Amy von Walter, a spokeswoman for the company. She declined to comment on specifics of the IRS dispute or other elements of this story.

Medtronic says in court papers that its offshore unit paid the correct amount for rights moved out of the country.

The aftermath of the Puerto Rico tax credit illustrates the cat-and mouse game companies and the government play when Congress tries to close tax breaks.

"It is a cautionary tale," said Greg Ballentine, an economist in Washington with Charles River Associates, a consulting firm that advises companies on transfer pricing. "There is a very active and aggressive community of tax advisers out there, and they respond to whatever changes are made, congressional or regulatory. So the IRS is frequently several steps behind."

Tax incentives

Puerto Rico became a haven for the manufacturing operations of U.S. companies in the 1960s, when the federal government used various tax incentives to combat poverty and unemployment on the island, which now has almost 4 million residents.

In 1976, Congress added a tax credit that effectively exempted from federal income taxes the profits that U.S. companies attributed to Puerto Rico. The combination of the break, proximity to the mainland and plentiful industrial sites prompted multinational companies to flock to the island, with medical-device and pharmaceutical makers leading the way, including Pfizer, Eli Lilly and Merck.

After a lobbying battle in 1996, the tax break was repealed, with a 10-year transition period for companies already benefiting from the credit.

"There was certainly an expectation the companies would react" after the repeal, said Daniel M. Berman, a former deputy international tax counsel at the Treasury Department at the time of the dispute over the tax break.

After losing the legislative fight, corporate tax accountants and lawyers took action. While manufacturing facilities stayed in Puerto Rico, dozens of firms shifted the ownership of those assets to new subsidiaries in tax havens around the world.

One of the leading strategists behind the new tax maneuvers was Ernest Aud Jr., a veteran international tax lawyer for the accounting firm Ernst & Young in Chicago. "We were the ones that made companies aware that there was an opportunity -- underscore opportunity -- to maybe do better under" the new arrangement than under the old Puerto Rico break, said Aud, now retired.

Among those taking advantage of that opportunity was Medtronic. In August 2001 -- about four years before the tax credit would end -- Medtronic established a subsidiary in Grand Cayman, listing an address at an office now used by Intertrust Group Holding, a corporate-services provider that helps companies establish shell subsidiaries in tax havens.

On paper, Medtronic transferred ownership of its Puerto Rican assets to this new Cayman unit, called Medtronic Puerto Rico Operations Co. The Cayman subsidiary is owned by a Dutch arm, which is in turn owned by a Swiss subsidiary, court filings show. In 2006, Medtronic transferred some of the Dutch company's assets to the unit in Zug, Switzerland, a popular destination for companies seeking Swiss tax holidays.

The new Cayman entity also entered into an arrangement to pay royalties to the U.S. parent to use intellectual property and other rights covering devices it manufactures in Puerto Rico and then sells back into the mainland. The IRS contends that Medtronic's Cayman unit underpaid for those rights, court papers show, shifting offshore income from U.S. sales.

Taxes on such offshore profits are typically deferred indefinitely until the companies decide to bring the earnings back to the United States.

Medtronic's tax rate has plummeted. In 1995, the year before Congress abolished the Puerto Rico credit, the break cut 4.2 percentage points off the company's effective tax rate, helping to lower it to 33.5 percent. By 2011, Medtronic's tax rate was down to half that.

Overall, the savings from the low-taxed overseas income boosted Medtronic's net income in fiscal 2011 by 30 percent, to $3.1 billion, based on tax disclosures in the firm's most recent annual report.

"The government underestimated how sophisticated and aggressive multinationals would be in shifting truckloads of profits out of the U.S.," Harvard's Shay said.