Updated

The fire marshal of Oakland, Calif., resigned Friday following harsh criticism over two fires in the city that killed a total of 40 people.

The departure of Marshal Miguel Trujillo became the latest black eye for the Bay Area city during the administration of Democratic Mayor Libby Schaaf, who has clashed with the Trump administraion over immigration policy.

The marshal's resignation was announced by Fire Chief Darin White, who will handle Trujillo’s duties running the fire inspection bureau while a replacement is sought.

Trujillo faced months of scrutiny on the “overextended, often-troubled” fire prevention unit he led, the San Francisco Chronicle reported.

He leaves now for Gilroy, Calif., where he will be fire marshal for a city that’s one-eighth the size of Oakland, the report said.

Trujillo’s resignation adds to the department’s beleaguered fire inspection bureau, which was intensely scrutinized after 36 people died in a Dec. 2, 2016, fire at the "Ghost Ship" warehouse, and four people died in a March 27, 2017, fire at a halfway house, the East Bay Times reported.

OAKLAND-FIRE/

Firefighters battle a four-alarm blaze in a three-story apartment building in Oakland, Calif., March 27, 2017. (Reuters)

The Ghost Ship warehouse had been illegally converted into living space for artists and had no fire sprinklers. Trujillo’s department reportedly never inspected the building, and it was not on the city’s inspection rolls despite firefighters having been called there several times, the Times reported. A fire official also said he filed a report noting dangers two years prior to the blaze.

In the halfway house blaze, internal emails showed that firefighters repeatedly warned of potential safety hazards there over several months, but an inspection wasn’t done until three days before the blaze, the report said. Despite serious violations, the site -- home to as many as 100 people -- was reportedly allowed to stay open.

A subsequent investigation by the Times found that 80 percent of the referrals made by firefighters to the Fire Prevention Bureau of dangerous conditions in buildings were not inspected.

Assistant Fire Marshal Maria Sabatini detailed how short-staffed and “crazy busy” the bureau was, in an internal email obtained by the Mercury News. She also attributed the lack of inspections to “ongoing miscommunication” between firefighters and inspectors on the proper guidelines to refer buildings for inspection.

Trujillo did not immediately responded for comment.

In addition to the fatal fires, Oakland since the arrival of Mayor Schaaf in January 2015 has seen a sex scandal involving members of the police department -- leading to a period in which the city had three police chiefs within a week.

Mayor Schaaf also became the center of controversy earlier this year when she publicly warned that U.S. Immigration and Customs Enforcement officers would be conducting raids in the city.

The Associated Press contributed to this report.