A US judge has ruled a congressional committee investigating the Capitol riot can access some of ex-President Donald Trump's White House records.
Mr Trump had sought to invoke executive privilege, under which presidential documents can be kept secret.
The inquiry is trying to find out if Mr Trump had prior knowledge of the riot.
Trump supporters stormed the Capitol building on 6 January as Congress was certifying President Joe Biden's election victory.
Mr Trump has refused to acknowledge losing the election last year, claiming - without evidence - that it had been rigged.
The inquiry is being conducted by a committee set up by the House of Representatives which is dominated by President Biden's Democrats.
The panel wants to see a trove of phone records, visitor logs and other White House documents that could shed some light on the events leading up to the attack on Congress.
It has issued summonses to several Trump aides to testify before the lawmakers.
Mr Trump - a Republican - had argued his White House communications were protected and as such should not be released.
But US District Judge Tanya Chutkan ruled that the National Archives, the federal agency that holds the records, should comply with the panel's request.
In a 39-page ruling, Judge Chutkan said that Congress had the right to see the documents, particularly as the current president had agreed.
Mr Trump "does not acknowledge the deference owed to the incumbent president's judgment. His position that he may override the express will of the executive branch appears to be premised on the notion that his executive power 'exists in perpetuity,'" the judge wrote. "But presidents are not kings, and plaintiff is not president."
As a former president, Mr Trump enjoyed the right to executive privilege, she added, but the incumbent president "is best situated to protect executive branch interests".
However, it is unlikely the records will be accessible in the near future.
The legal battle is likely to wind up at the Supreme Court.
A spokesman for Mr Trump, said the case was likely to be appealed.
Taylor Budowich said Mr Trump was committed to defending the right of US presidents to assert executive privilege and "will be seeing this process through".
But Bennie Thompson, the Mississippi Democrat who is chairman of the committee, called the lawsuit "little more than an attempt to delay and obstruct our investigation."
Sixteen of Mr Trump's closest aides have been subpoenaed in the past two days.
They include Kayleigh McEnany, the White House press secretary, Stephen Miller, who was Mr Trump's senior adviser, Bill Stepien, campaign manager, Mark Meadows, former White House chief of staff, and Michael Flynn, former national security adviser.
Bennie Thompson, the Mississippi Democrat who chairs the House committee, said in a statement he wanted to know every detail about what happened on 6 January, and in the days leading up to it.
The committee expects the witnesses to "comply fully", he added.
The panel has already subpoenaed Dan Scavino, former deputy chief of staff, and Steve Bannon, a former Trump strategist.
Mr Bannon refused to comply with the subpoena and was charged with contempt of Congress.
Following the Capitol riot, Mr Trump was impeached by the lower house of Congress, but cleared by the then Republican-dominated upper house, the Senate, of inciting an insurrection.
More than 670 people have been arrested for the invasion of the Capitol complex.