WASHINGTON — The Trump administration announced Friday that it would discontinue former President Barack Obama’s policy of voluntarily disclosing the names of most visitors to the White House complex, citing “grave national security risks and privacy concerns.”

Instead, the White House said it would honor Freedom of Information Act requests for such records only for components of the White House that are classified under the law as agencies, such as the Office of Management and Budget. The new policy excludes visits to the president, vice president and their senior staff.

The Trump administration was sued in federal court earlier this week by a coalition of watchdog groups in a bid to compel the same release of records made public under Obama.

Since Trump took office in January, the website where such records had been publicly available has gone dark, and Trump administration officials said Friday that they will no longer maintain it.

Obama’s policy was crafted in 2009 in response to a series of lawsuits. The policy permitted some exceptions to disclosure, including purely private visits to the Obama family, such as friends arriving for sleepovers with the president’s school-age daughters. The Obama White House also maintained the prerogative not to release records of particularly “sensitive” meetings, such as interviews with potential Supreme Court nominees.