President Biden met over the past two days with Robert K. Hur, the special counsel investigating how classified documents improperly ended up at Mr. Biden’s home and an office he used after leaving the vice presidency, the White House disclosed on Monday.

“The voluntary interview was conducted at the White House over two days, Sunday and Monday, and concluded Monday,” Ian Sams, a White House spokesman, said in a statement.

The interview played out amid the dramatic events in the Middle East, as Hamas militants carried out a major attack on Israel and Mr. Biden met with his national security team and consulted with foreign leaders. The interview’s timing had been arranged several weeks ago, according to a person familiar with the matter.

Wyn Hornbuckle, a spokesman for Mr. Hur, declined to comment.

The interview raises the possibility that Mr. Hur is nearing the end of his investigation, which the Justice Department began after Mr. Biden’s lawyers reported that they had found several classified documents mixed in with other papers in a storage closet while packing up an office at a Washington think tank, the Penn Biden Center for Diplomacy and Global Engagement.

Mr. Biden had periodically used the space after leaving the vice presidency in 2017 and before he began his presidential campaign. A search of Mr. Biden’s house in Delaware later turned up several more such documents, and in January Attorney General Merrick B. Garland appointed Mr. Hur, a former Trump-era U.S. attorney for Maryland, as a special counsel — a prosecutor with a degree of day-to-day autonomy to handle sensitive investigations — to investigate the matter.

The inquiry has unfolded against the charged backdrop of another special counsel investigation, into former President Donald J. Trump’s handling of classified documents he took to his Florida club and residence, Mar-a-Lago, and his refusal to give them all back even after being subpoenaed.

Mr. Trump has repeatedly claimed that he had a right to hold onto the documents, and the prosecutor in that case, Jack Smith, has charged him with unauthorized retention of national security secrets and obstruction, among other counts.

By contrast, Mr. Biden has portrayed himself as surprised to learn that classified documents were improperly mixed in with copies of papers from his previous office, and his team has sought to portray itself as being cooperative with the investigation.

Mr. Hur’s investigation has proceeded relatively quietly. Unlike in Mr. Trump’s case, there have been no known fights before a grand jury over claims of executive privilege and other matters that led to numerous disclosures about recalcitrant witnesses receiving subpoenas — frictions that increased chatter that in turn helped give the public more glimpses of that investigation’s progress.

But over the past nine months, Mr. Hur appears to have been exhaustively interviewing everyone with insight into how the documents were packed and moved, as well as how Mr. Biden’s team handled their discovery.

Among the many current and former Biden aides who have spoken with Mr. Hur, according to people familiar with the matter, are Dana Remus, his first White House counsel, and Ron Klain, his first White House chief of staff. They are also said to include Jake Sullivan, the national security adviser, and Antony J. Blinken, the secretary of state; both had been national security aides to Mr. Biden when he was vice president.

In his statement, Mr. Sams said little more, referring further questions to the Justice Department, which has consistently declined to comment on the substance of the inquiry.

“As we have said from the beginning, the president and the White House are cooperating with this investigation, and as it has been appropriate, we have provided relevant updates publicly, being as transparent as we can consistent with protecting and preserving the integrity of the investigation,” Mr. Sams said.