WASHINGTON — The Obama administration in its final year in office spent a record $36.2 million on legal costs defending its refusal to turn over federal records under the Freedom of Information Act, according to an Associated Press analysis of new U.S. data that also showed poor performance in other categories measuring transparency in government.

For a second consecutive year, the Obama administration set a record for times federal employees told citizens, journalists and others that despite searching they couldn’t find a single page of files that were requested.

And it set records for outright denial of access to files, refusing to quickly consider requests described as especially newsworthy, and forcing people to pay for records who had asked the government to waive search and copy fees.

READ MORE: Obama administration sets new record for withholding FOIA requests

The government acknowledged when challenged that it had been wrong to initially refuse to turn over all or parts of records in more than one-third of such cases, the highest rate in at least six years.

In courtrooms, the number of lawsuits filed by news organizations under the Freedom of Information Act surged during the past four years, led by the New York Times, Center for Public Integrity and The Associated Press, according to a litigation study by the Transactional Records Access Clearinghouse at Syracuse University. The AP on Monday settled its 2015 lawsuit against the State Department for files about Hillary Clinton’s time as secretary of state, at AP’s request, and received $150,546 from the department to cover part of its legal fees.

The AP has pending lawsuits against the FBI for records about its decision to impersonate an AP journalist during a criminal investigation and about who helped the FBI hack into a mass shooting suspect’s iPhone and how much the government paid to do it.

Of the $36.2 million in legal costs fighting such lawsuits last year, the Justice Department accounted for $12 million, the Homeland Security Department for $6.3 million and the Pentagon for $4.8 million. The three departments accounted for more than half the government’s total records requests last year.

The figures reflect the final struggles of the Obama administration during the 2016 election to meet President Barack Obama’s pledge that it was “the most transparent administration in history,” despite wide recognition of serious problems coping with requests under the information law. It received a record 788,769 requests for files last year and spent a record $478 million answering them and employed 4,263 full-time FOIA employees across more than 100 federal departments and agencies. That was higher by 142 such employees the previous year.

A spokesman for former President Obama did not immediately respond to an email request for comment late Monday. The White House under Obama routinely defended its efforts under the information law in recent years and said federal employees worked diligently on such requests for records.

MORE: How a senior Obama adviser views his record

It remains unclear how President Donald Trump’s administration will perform under the Freedom of Information Act or other measures of government transparency. Trump has not spoken extensively about transparency. In his private business and his presidential campaign, Trump required employees and advisers to sign non-disclosure agreements that barred them from discussing their work. His administration has barred some mainstream news organizations from campaign rallies and one White House press briefing. And Trump broke with tradition by refusing to disclose his tax returns.

Trump’s secretary of state, Rex Tillerson, is traveling to Asia this week on a small plane without a contingent of journalists or a designated pool reporter who would send reports to the broader diplomatic press corps, departing from 50 years of practice.

Overall, in the final year of Obama’s administration, people who asked for records last year under the law received censored files or nothing in 77 percent of requests, about the same as the previous year. In the first full year after Obama’s election, that figure was only 65 percent of cases. The government released the new figures in the days ahead of Sunshine Week, which ends Sunday, when news organizations promote open government and freedom of information.

Under the records law, citizens and foreigners can compel the U.S. government to turn over copies of federal records for zero or little cost. Anyone who seeks information through the law is generally supposed to get it unless disclosure would hurt national security, violate personal privacy or expose business secrets or confidential decision-making in certain areas.

MORE: The Obama Years