FORTUNE — When Oracle reported its latest quarterly earnings last month, most investors focused on the fact that its dividend doubled. The number that got less notice in its annual report a week later was its low tax bill — nearly half the standard 35% corporate rate.  It’s a significant change from a decade ago, when the software giant began thinking about higher tax costs amid plans for growth. It turned to an obscure solution: confidential pacts forged between the Internal Revenue Service and multinational corporations that critics say can unwittingly bless aggressive tax strategies. In 2003 Oracle disclosed for the first time that it had sealed two such long-term pacts with the IRS and was negotiating additional ones.  The pacts, known as advance pricing agreements, effectively lock the IRS into agreeing with a company’s tax planning over many years, both future and past. Despite costing companies up to millions of dollars in fees to prepare and taking up to four years to seal, the agreements are nonetheless worth it to an elite group of big corporations that have them, including Google GOOG , Apple AAPL , and Amazon AMZN .  The inner workings of the pacts, whose effects are sometimes not seen until years later, are not disclosed due to taxpayer confidentiality laws. Oracle ORCL has not been accused of any wrongdoing. Still, the deals appear to have worked for the company: In fiscal 2003, its company’s tax rate was 32%, reflecting $1.1 billion in cash income taxes paid to federal, state, local, and foreign collectors, on pre-tax income of more than $3.4 billion, securities filings show.  MORE: Detroit’s bankruptcy is an utter defeat  Fast-forward a decade, over which Oracle finalized four more pacts, including two governing foreign tax benefits, generally covering fiscal years 2002 through 2013, excepting 2006. It also consolidated hundreds of offshore subsidiaries into six core affiliates in Ireland, and by this year had amassed $26 billion in cash held overseas — more than seven times 2003’s level. As of May, when its 2013 fiscal year ended, Oracle had nearly halved its tax bill. It paid $2.6 billion in cash income taxes on pre-tax income of nearly $13.9 billion, a rate of just under 19%.  Jessica Moore, a spokeswoman for Oracle, declined to respond to questions about its tax deals.  Widening scrutiny of declining corporate tax bills has singled out the growing use of post office-box subsidiaries in offshore tax havens to hoard cash stockpiles and whisk profits away from higher-tax jurisdictions. Now some experts wonder if advance pricing agreements, perfectly legal under U.S. law and growing in number, sometimes play a major role in helping to shift some of those profits and drive down corporate tax bills.  “There’s a lot of confidential information in these deals, because it’s where companies make their profits,” said Patricia Lewis, a tax lawyer at Caplin & Drysdale who helps companies negotiate the pacts.  When applying for an agreement, companies must lift the curtain on their tax planning and convince the IRS that it is legitimate. The plan does not always work: Eaton Corp., a hydraulics maker, sued the IRS last year after the agency revoked its two pacts a year earlier and slapped it with a $369 million tax bill, not including penalties. Last month, a Tax Court judge said the closely-watched case could proceed and might go to trial.  MORE: Reining in the audit industry’s reality distortion field  Under the deals, the IRS agrees not to challenge the complex financial calculations underpinning the exchange of assets, goods, intellectual property, and money between a company and its overseas subsidiaries, typically in offshore havens like Ireland or the Cayman Islands. The exchange, known as transfer pricing, is supposed to be tallied at arm’s length prices, but different methodologies can produce different results. What’s clear, tax lawyers say, is that the calculations can be among the single biggest factors in lowering a company’s tax bill and boosting after-tax profits.  But some critics argue that through the pacts, the IRS can sometimes give up too much, particularly in an area — transfer pricing — that it increasingly considers a primary means of tax abuse by multinational corporations. “Of course companies are sneaking things by the IRS with these deals — look, they are seeking to get authorization for something they know might not pass muster otherwise,” says Robert McIntyre, director of Citizens for Tax Justice, a left-leaning advocacy and research group.  Says Craig Sharon, a former director of the IRS’s APA program: “It’s possible to get a worse result than you would through an audit, but it’s also possible to get a better result.”  The manipulation of complex cross-border pricing by multinationals with subsidiaries in low-tax jurisdictions is a growing concern inside the IRS, which in 2011 created a new unit to deal with the problem and said it was developing a strategy to litigate abusive cases. Last year it moved its advance pricing program into the unit, saying it wanted to speed up processing of pact applications.  But if the new unit is a stick, the pricing agreements appear at times to be a carrot. The IRS approved a record 140 pacts last year, more than triple the number in 2011. Another 182 are pending renewal. Overall, since the program began in 1991, 1,155 pacts have been executed, IRS data shows. The biggest users are financial services companies with large cross-border trade, and technology and pharmaceutical companies.  MORE: Interest rates 101: Why the party is over  Because the details of pacts are not public — some companies don’t even disclose that they have them — there is no way to know how the IRS is making decisions regarding murky areas of tax law. Critics argue that the process effectively creates a secret body of law, one that might not be applied evenly across companies. Shareholders know nothing of their details. And some tax experts say the IRS, loath to lose legal cases against corporations it sues to collect back taxes, is being more generous than it would be in an audit. “There’s a certain amount of compromise on both sides,” admitted one former director of the IRS’s advance pricing agreement program.  The IRS has always struggled to ferret out tax strategies that skirt the law or take advantage of gray areas. And it has had a dismal record of challenging transfer pricing issues in court — in 2010 it lost a case seeking more than $1 billion from software maker Veritas, now part of Symantec SYMC . So when the agency created a program for the pacts, in 1991, it envisioned a way to lighten its burden of scrutinizing a company’s books.  The IRS says the pacts are “designed to resolve actual or potential transfer pricing disputes in a principled, cooperative manner, as an alternative to the traditional adversarial process.” Michael Durst, a former director of the program, who is now at Steptoe & Johnson, said that “the goal, from the standpoint of the IRS, is that APAs won’t either increase or reduce companies’ tax bills — instead, an APA will achieve the same result that a company would have reached after audit and possible litigation, but without all of the uncertainty and transaction costs.”  “Has the APA program contributed to abuses?” asked Sharon. “I would say, not intentionally.”
Oracle, Google, and Amazon are just a few of the hundreds of large companies that have cut confidential deals with the IRS to help lower their tax bills, and critics want the agency to disclose the details of these complex pacts.