Bitcoin exchange Coinbase has lost a bid to keep the IRS from seeing customers' trading records as part of a tax-avoidance probe.

US Magistrate Judge Jacqueline Scott Corley for the US District Court in San Francisco ruled Wednesday that the exchange must supply the tax agency with the identities of all users in the US who conducted at least one bitcoin transaction equivalent to at least $20,000 between 2012 and 2015. Corley said a "reporting gap" gave the IRS legitimate reason to demand the information.

"That only 800 to 900 taxpayers reported gains related to bitcoin in each of the relevant years and that more than 14,000 Coinbase users have either bought, sold, sent or received at least $20,000 worth of bitcoin in a given year suggests that many Coinbase users may not be reporting their bitcoin gains," Corley wrote in her judgment. "The IRS has a legitimate interest in investigating these taxpayers."

The Justice Department said in a filing last year that an IRS agent had identified three cases in which cryptocurrencies were used to avoid paying taxes. Two of those cases involved Coinbase customers with millions of dollars in annual revenues, the filing alleged.

The ruling comes as bitcoin makes historic valuation gains on a near daily basis. Bitcoin, which attracted attention by allowing for anonymous transactions, on Wednesday traded at more than $11,000 per coin for the first time, a day after it broke the $10,000 barrier. The cryptocurrency's value has increased 1,000 percent since the beginning of the year.

With the order, Coinbase will be required to turn over the names, addresses and tax identification numbers on 14,355 account holders out of its nearly 6 million customers.

Coinbase, the largest bitcoin exchange in the US, has opposed the demand since last year, arguing it was "extremely concerned with the indiscriminate breadth of the government's request."

Coinbase said that while it was disappointed the court didn't quash the summons completely, it was pleased the judge narrowed the scope of records demanded and reduced the quantity of data it must give the IRS.

"While today's result is not the complete victory we hoped for, it does represent a substantial and unprecedented victory for the industry and the hundreds of thousands of customers that would have been unfairly targeted if it weren't for our action," David Farmer, Coinbase's director of communications, said in a blog post.

Updated at 5:20 p.m. PT with Coinbase comment.

Special Reports: All of CNET's most in-depth features in one easy spot.

It's Complicated: This is dating in the age of apps. Having fun yet? These stories get to the heart of the matter.