The search carried out on Monday by the F.B.I. at former President Donald J. Trump’s Florida home, a law enforcement action with explosive legal and political implications, was the culmination of a lengthy conflict between a president proud of his disdain for rules and officials charged with protecting the nation’s records and secrets.
On one side were officials from the National Archives, which is responsible for making sure all presidential records are preserved according to the law, and the Justice Department, which some people familiar with the inquiry said had grown concerned about the whereabouts of possible classified information and whether Mr. Trump’s team was being fully forthcoming.
On the other was Mr. Trump, who, in apparent contravention of the Presidential Records Act, had taken a trove of material with him to his home at Mar-a-Lago when he left the White House that included sensitive documents — and then, in the Justice Department’s view, had failed to fully comply with requests that he return the disputed material.
After the investigation bubbled along largely out of public view for months, word that agents had arrived early Monday morning at the gates of Mar-a-Lago with a search warrant raised new questions about Mr. Trump’s vulnerability to prosecution and fueled further partisan division.
Mr. Trump’s aides and allies intensified their criticism of the search on Tuesday, calling it unnecessary and asserting, without citing any evidence, that it was a brazen use of prosecutorial power for political purposes. On his social media site on Tuesday, Mr. Trump cast the search as part of “a coordinated attack” that also includes local and state prosecutors, alluding to investigations into him being carried out in Georgia and New York.
Christina Bobb, a lawyer and aide to Mr. Trump who said she received a copy of the search warrant, told one interviewer that the agents were looking for “presidential records or any possibly classified material.”
At the White House, President Biden’s press secretary said he had no advance word of the decision to carry out the search, and at the Justice Department, Attorney General Merrick B. Garland maintained public silence about the momentous step.
Despite Mr. Trump’s suggestions that an army of agents raided Mar-a-Lago and stormed through his home, the F.B.I. conducted the search on a day when Mr. Trump was out of town and the club was closed. The agents carried out the search in a relatively low-key manner, people with knowledge of the matter said; by some accounts they were not seen donning the conspicuous navy-blue jackets with the agency’s initials emblazoned on the back that are commonly worn when executing search warrants.
Another person familiar with the search said agents began going through a storage unit, where items like beach chairs and umbrellas are kept, in the basement. They progressed to his office, which was built for him on the second floor of the main house, where they cracked a hotel-style safe that was said by two people briefed on the search to contain nothing of consequence to the agents.
Then they moved to Mr. Trump’s residence, the person said.
Ultimately, they removed a number of boxes of documents, people familiar with the search said.
It is not clear what the agents were looking for or what they took. Nor is it clear whether the search was carried out simply to ensure that the documents and other material were properly turned over to the archives or it was a possible precursor to a prosecution of Mr. Trump for mishandling classified material or obstructing efforts to get it back.
Throughout his presidency, Mr. Trump was disdainful of record-preservation laws, and was known to tear up documents and in some cases to flush them down toilets. It is not clear whether he sought to hold onto material sought by the archives and the Justice Department to keep it away from public scrutiny or for some other reason.
A close look at the investigation, though, shows how it has been quietly picking up steam for much of this year, introducing a new element into the questions about Mr. Trump’s varied and intensifying legal problems and his political viability even as he hints at another run for the presidency.
For many months before he left office, Mr. Trump would tell aides to bring documents up to the residence for him while he was in the Oval Office, and they complied, but there was no process in place, meaning that officials whose job it was to keep track of paperwork did not always know exactly what had gone up there, according to people familiar with the events.
By the end of his presidency, and as Mr. Trump was fighting to overturn his election loss, some of his aides were concerned with preserving the work of the office itself. His habit of transporting material around in cardboard boxes, with either a personal aide or a valet carrying them, was well known, but the contents were not always clear.
Discussions were held within the White House by top staff members about how to get Mr. Trump to surrender his boxes, people familiar with the events said; it is unclear whether Mr. Trump was ever asked directly or officials simply did not take the issue to him.
When he left the White House, Mr. Trump took the boxes with him to Mar-a-Lago, packed with paperwork including letters from the North Korean leader Kim Jong-un and the former president’s “Sharpie-gate” map of the path of a hurricane, along with personal items like golf balls and a rain coat and various other things stuffed in.
The National Archives, whose mission is to preserve government documents, determined last year that many important presidential documents that archivists knew existed were missing and believed to be in Mr. Trump’s possession.
That set off a lengthy back and forth between the National Archives and Mr. Trump’s lawyers about what documents he might have taken. Mr. Trump’s unwillingness to quickly hand over the documents frustrated archives officials, who had grown deeply skeptical throughout the Trump administration that he and his aides followed federal record keeping laws.
For the rest of 2021, Mr. Trump resisted requests to give back the material. In the meantime, Mr. Trump would wave things like the North Korean leader’s letters at people, as if they were collectors’ items he was showing off.
In January of this year, an official for the National Archives flew to Florida and retrieved 15 boxes of documents, gifts and other government property.
When archivists went through the boxes, they found several documents containing sensitive national security information, including some marked classified.
The archivists also discovered that Mr. Trump had not returned several documents that they believed the former president had in his possession. Around this time, the National Archives alerted the Justice Department that it was concerned about the handling of the classified documents, which are closely tracked by the government and are supposed to remain within secure channels.
By this spring, the Justice Department had taken a range of steps that showed it was conducting an investigation into what happened with the classified documents, as prosecutors issued a subpoena to the National Archives to obtain the boxes and convened a grand jury, whose term was later extended past its initial expiration date.
Investigators began contacting possible witnesses, including Molly Michael, an assistant to Mr. Trump, signaling that they were seeking information from people close to the former president. A lawyer for Ms. Michael declined to comment.
During the spring, a group of federal investigators, including the Justice Department’s top counterintelligence official, Jay Bratt, traveled to Mar-a-Lago. Mr. Trump met with them briefly, and lawyers for Mr. Trump were present.
In an interview on Tuesday with the right-wing channel Real America’s Voice, Ms. Bobb said she and other Trump lawyers had been “extremely cooperative” with the F.B.I. during a previous visit when agents were given “free access” to the building.
After Mr. Bratt and other officials visited Mar-a-Lago, they subpoenaed the Trump Organization for a copy of Mar-a-Lago’s surveillance tapes, a person with knowledge of the matter said. The company complied, turning over the tapes to the government.
Mr. Trump’s lawyers also sifted through his records at Mar-a-Lago to determine whether he still was holding onto anything classified or sensitive. In the course of that process, Mr. Trump’s team made statements to the Justice Department about what Mr. Trump had returned.
But in recent weeks, officials came to question whether that information was entirely accurate — and whether Mr. Trump continued to store sensitive documents at Mar-a-Lago, one of the people said. It is unclear whether the department conveyed that concern to Mr. Trump’s team.
Mr. Trump and his aides have made clear that they were taken by surprise when the agents showed up at Mar-a-Lago with a search warrant on Monday.
A person with knowledge of the matter said the warrant was approved by a federal magistrate judge, Bruce Reinhart, a former federal prosecutor and defense lawyer. Magistrate judges are selected by district court judges, meaning that they are not political appointees. It is common for magistrates to review search warrant applications.
The warrant was obtained by prosecutors with the Justice Department’s national security division, which at the request of the National Archives has been leading the investigation into whether the materials were improperly removed and stored, according to two people with knowledge of the situation.
The F.B.I. left behind a detailed manifest of all the materials that were removed, according to a person familiar with the investigation.
Glenn Thrush and Katie Benner contributed reporting.