Medtronic stands to gain a one-time cash windfall of about $3 billion, if a ruling from a U.S. Tax Court judge holds up.

The Minnesota-run maker of medical devices has spent the past decade in a dispute with the Internal Revenue Service over the U.S. taxes it owes from its manufacturing operations in Puerto Rico in the mid-2000s.

Last week, U.S. Tax Court Judge Kathleen Kerrigan sided with Medtronic in a 144-page ruling, saying that the IRS had not proved its case that Medtronic owed $1.4 billion more in taxes from its Puerto Rico operations than the company paid in 2005 and 2006.

Drawing on testimony from a trial last year, Kerrigan ruled on June 9 that Medtronic had successfully shown the IRS’ interpretation of Medtronic’s tax obligations were “arbitrary, capricious, or unreasonable.”

The ruling would free up $1.4 billion set aside on Medtronic’s financial statements to cover the IRS demands for 2005 and 2006. If the same logic applied to all tax years from 2005 forward, the total impact is more than $3 billion, according to a Medtronic estimate.

A Medtronic spokesman said that the company is continuing to analyze the ruling, and that a final resolution could take several months or longer if an appeal is filed.

“Our preliminary review indicates that this decision appears to be favorable to Medtronic on many key aspects of the case, and it appears to be generally consistent with the company’s most likely scenario for resolution that has previously been communicated to investors,” spokesman Fernando Vivanco said via e-mail. “We will continue to assess the 144-page ruling and will provide any additional guidance as required.”

Four days before the ruling, Chief Financial Officer Gary Ellis told Medtronic investors at a company event in New York that the most likely outcome would be for the tax court to adopt similar terms to a past agreement between the company and the IRS before the dispute arose.

In that scenario, Medtronic would gain access to about $3 billion that was recorded on company financial statements from 2005 onward but considered “trapped” because it was tied up in the tax dispute. Such a ruling would also cut future tax expenses related to the Puerto Rico manufacturing operations by at least $225 million annually going forward, Ellis estimated.

“We’ve been trapping more cash there, in Puerto Rico, because we were assuming more profits were captured there,” based on the 2005 and 2006 IRS adjustments, Ellis told investors June 6.

The so-called transfer-pricing dispute turns on the question of how much value is created by Medtronic’s Puerto Rico manufacturing facilities, and how intellectual property and income are shared among separate business units of the same company.

Corporate taxes are generally higher in the United States than in Puerto Rico, so corporations have an incentive to book income through subsidiaries there. But companies also have a responsibility to assess the fair value of the services and goods supplied by their U.S.-based parent companies, and compensate them for those.

In 2005 and 2006, Medtronic Puerto Rico Operations Co. (MPROC) manufactured pacemakers, implantable defibrillators and neurostimulators for pain, as well as the advanced wires called leads that doctors place inside patients’ blood vessels to carry electric current from the pulse generator to the heart tissue or nervous system.

The IRS used an economic analysis that found Medtronic had “vastly overstated” the amount of profits attributable to the company’s Puerto Rico manufacturing plant, considering that the U.S.-based operations performed most of the functions and bore most of the risks related to manufacturing pacemakers and neurostimulators, Kerrigan wrote.

But the judge disagreed with the IRS analysis, finding that the tax agency’s analysis “was dismissive of the importance of MPROC’s role in quality. It also considerably downplayed the role of MPROC.”

Medtronic shares were unchanged Monday, closing at $85.70.