A complex, years-long legal battle between Facebook and the IRS will finally be resolved in court, as the company attempts to fend off tax liability that could cost it some $9 billion.

The trial will begin this week in U.S. Tax Court, where the IRS will argue that more of Facebook's profits should have been taxed at the higher U.S. rate, rather than in the company's Irish subsidiary, the Wall Street Journal reported.

Bertie Thomson, a Facebook spokeswoman, said the company looks forward to presenting its case in court.

'This trial is about transactions that took place in 2010, when Facebook had no mobile advertising revenue, its international business was nascent, and its digital advertising products were unproven,' she told the Journal in a statement. 'Our business has had hits and misses but we stand behind the actions taken over a decade ago during a time of great risk and uncertainty for the company.'

Facebook will go to trial this week in US Tax Court over a long-running dispute about its overseas profits. Pictured: Facebook CEO Mark Zuckerberg is seen last year

The government has said in court documents that in 2010 Facebook Inc sold the rights to exploit the Facebook platform outside the United States and Canada to Facebook Ireland Holdings.

The price used for the intangible property was determined by Facebook's tax adviser Ernst & Young (E&Y).

'The IRS examination team's preliminary positions suggested that the E&Y valuations of the transferred intangibles were understated by billions of dollars,' the lawsuit said. E&Y was not immediately available for comment.

Facebook Ireland Holdings in turn leased the rights to exploit the Facebook platform to its own subsidiary, Facebook Ireland Ltd, in return for a fee, accounts for Facebook Ireland Ltd, filed with the Irish company registry, show.

Facebook Ireland Ltd. is Facebook's main international business unit, reaping sales of 4.8 billion euros in 2014, the last year for which accounts are available.

Facebook Inc in the United States could have licensed its intellectual property directly to Facebook Ireland Ltd but then it would have to report that income in the United States and pay tax there.

A thumbs up symbol stands at the entrance to the Facebook Inc. European headquarters in Dublin, Ireland in a file photo

It does have to pay tax on the money it received from intermediary Facebook Ireland Holdings.

Moreover, if Facebook Ireland Holdings paid less for the rights than it charges Facebook Ireland Ltd., this margin allows profit to be built up in the lower tax jurisdiction.

U.S. technology companies sometimes don't even have to pay the 12.5 percent Irish corporate tax rate.

They frequently take advantage of a quirk of Irish tax law which allows companies to designate an Irish registered company as being tax resident elsewhere -- an arrangment tax professionals have termed a 'double Irish'.

This involves the rights-holding company being designated as tax resident in a tax haven. However, since the companies concerned are Irish-registered, the transactions don't trigger a U.S. tax bill.

Facebook previously declined to say where Facebook Ireland Holdings was tax resident. It is an unlimited company, which means it doesn't have to file accounts so there are no public documents on its status.