New York (CNN Business) Amazon hasn't paid any taxes to the US government in the past two years. Actually, Amazon received hundreds of millions of dollars in federal tax credits in 2017 and 2018.

That might seem nuts, considering Amazon is the third-most valuable company in the world and earned a record $10 billion last year. But critics of Amazon's tax bill aren't accusing Amazon of doing anything improper.

"This is tax avoidance, not tax evasion. There's no indication of any wrongdoing, except on the part of Congress," said Matthew Gardner, senior fellow at the Institute on Taxation and Economic Policy, a liberal think tank.

US tax code allows money-losing companies to reduce their future taxable income.

piled up billions of dollars in losses over its two-decade history. It posted $3 billion worth of losses during its first eight years as a public company. It swung between profit and loss since 2003. Its most recent annual loss was $241 million in 2014.

Amazon's total earnings have easily topped its losses — many times over. But some of Amazon's earnings came from sales outside the United States, on which Amazon paid either lower or no US taxes. Other earnings were offset by Amazon's investments in equipment, such computers and robots at its fulfillment centers.

Last year, Amazon benefited from an accelerated tax credit for equipment purchases, which was part of the corporate tax bill passed at the end of 2017. And the company has received research and development tax credits. So Amazon's federal tax bill came to a net credit of $129 million in 2018 after getting a $137 million tax credit in 2017.

The company said in its most recent annual financial statement that it still has $1.4 billion in federal tax credits available to offset future tax bills.

General Motors GM Many companies that lose money pay little or no federal income taxes. For example,has paid little federal tax money since emerging from bankruptcy in 2009, despite posting record profits for several years. GM doesn't anticipate having to pay any significant federal tax for years to come.

Amazon, by contrast, paid $1.1 billion in federal taxes in 2016.

The company has also paid non-federal taxes. Amazon paid $533 million in state taxes and $1.3 billion in international taxes over the past two years.

Proponents of the federal tax law argue the tax credits for past losses, equipment purchases and research and development allow companies to invest for the future and grow.

"Amazon is a powerhouse company and it got there because it invested extensively," said Mark Zandi, chief economist at Moody's Analytics. "Most of our policies are much too short cited. This is one policy that rewards a longer-term perspective and taking some risk. Because of that, Amazon will ultimately be a big payoff for taxpayers."

But Gardner said Amazon's success makes such tax breaks unnecessary.

"It's hard to see a compelling argument that they would have been hamstrung in their ability to create jobs if they had been forced to pay taxes like everyone else does," said Gardner.

Amazon declined to comment on its federal tax payments.