Apple (AAPL) CEO Tim Cook defended the company’s tax practices Tuesday at a Congressional hearing that alternated between fawning and testy.

A report issued Monday from the Senate’s Permanent Subcommittee on Investigations revealed that the bulk of Apple’s profits are recorded by a pair of wholly owned Irish-based subsidiaries that pay few, if any, income taxes in any country.

In an appearance before that same subcommittee, Cook and his fellow executives noted that Apple has had the same basic arrangement since 1980. The company’s Irish subsidiaries do pay U.S. taxes on their investment income and its other subsidiaries pay local income taxes in the countries in which they operate, they said. And they argued that Apple designed the structure of its overseas operations for efficiency reasons, not tax avoidance.

What’s more, executives emphasized, Apple is likely the biggest payer of corporate income tax in America.

“We pay all the taxes we owe, every single dollar,” Cook said. “We not only comply with the laws, but we comply with the spirit of the laws.”

But some senators were skeptical of Apple and its actions and noted that the subcommittee hadn’t looked into the legality of the company’s tax strategies. Contradicting Cook, Sen. John McCain, R-Ariz., accused the company of violating the spirit of the tax code.

Through “convoluted and pernicious strategies,” Apple has managed to evade paying billions of dollars in taxes, he said.

While it’s true that Apple pays a lot of federal income taxes, Cook “failed to mention the less attractive fact that Apple is also one of biggest tax avoiders in America,” McCain said. “It’s given a new meaning to the company’s old slogan — ‘Think different’.”

McCain was joined in his criticism of Apple by subcommittee chairman Carl Levin, D-Mich. Levin argued that Apple made a conscious choice to allocate its profits to a “tax haven.” He noted that while 95 percent of Apple’s research and development is done in the United States, some two-thirds of the profits the company earns from its resulting intellectual property are recorded in Ireland.

“You shifted that golden goose to Ireland, to three companies that don’t pay taxes in Ireland and don’t even exist for tax paying purposes,” said Levin. “Don’t kid ourselves to the implications to what this means to America’s revenue.”

But other Senators, generally Republicans, rushed to Apple’s defense, arguing that the company was simply responding to an outdated tax code and was doing what was in the best interests of its shareholders.

“The tax code is a relic of the 60s,” said Sen. Rob Portman, R-Ohio. Arguing that Apple’s practices are an indication not of wrongdoing but that the tax system needed to be reformed, he added that Apple doesn’t “need more tax lawyers, you need more engineers.”

Tea Party favorite Rand Paul, R-Ky, went even further, charging the subcommittee with conducting a show trial and “bullying” Apple.

“This problem is solely and completely created by the awful tax code,” Paul said. “If anyone should be on trial here, it should be Congress. I frankly think this committee should apologize to Apple.”

No matter where they lined up on Apple’s tax practices, many subcommittee members were quick to praise the company’s products and its business success over the last decade. Showing off his iPhone, Levin noted, “I’ve got one right here. My granddaughter even knows how to use it.”

Contact Troy Wolverton at 408-840-4285. Follow him at Twitter.com/troywolv.