Acting homeland security secretary Chad Wolf abruptly resigned Monday, nine days before a presidential inauguration whose jittery security preparations are unfolding amid fears of worsening political violence following last week’s mob attack on the U.S. Capitol.

Wolf, who was overseas in the Middle East last week during the siege, attributed his decision to “recent events” and court rulings that have challenged the legality of his appointment by the Trump administration to run the department.

In a statement to Department of Homeland Security staff, Wolf said he was “saddened to take this step,” having previously announced plans to remain on the job through the end of the Trump administration.

“Unfortunately, this action is warranted by recent events, including the ongoing and meritless court rulings regarding the validity of my authority as Acting Secretary,” Wolf’s statement read. “These events and concerns increasingly serve to divert attention and resources away from the important work of the Department in this critical time of a transition of power.”

Chase Jennings, a DHS spokesman, said Wolf will remain at the department in his Senate-confirmed role as undersecretary for strategy, policy and plans.

Peter Gaynor, the administrator of the Federal Emergency Management Agency, will take over as acting DHS secretary, Wolf said.

Gaynor will be the agency’s sixth chief under President Trump, twice the number to serve under any previous administration. Established in the aftermath of the Sept. 11, 2001, terrorist attacks, the department was intended to reassure a nervous public by projecting stability and command.

Trump turned its focus toward the Mexico border and changed the department’s primary mission from counterterrorism to immigration enforcement.

Several lawmakers have called for hearings to question why Wolf and DHS failed to anticipate threats posed by Trump’s followers to Congress’s electoral college certification on Jan. 6. The Capitol Police, who are responsible for security at the building, had not requested DHS support in advance of the protests.

Wolf’s resignation comes at a time of high anxieties for federal law enforcement officials as they prepare for the possibility of violent attempts to disrupt the inauguration of President-elect Joe Biden. Pro-Trump militants have called for armed crowds to gather at all 50 state capitols, according to an FBI memo warning of the threat.

In one of his final moves as acting secretary Monday, Wolf announced that the U.S. Secret Service would take over security preparations for the inauguration on Wednesday, six days ahead of schedule.

The Secret Service, a DHS entity, typically plays the lead security role at presidential inaugurations. This year, as many as 15,000 National Guard troops will be mobilized to support the effort and protect the event. Busloads of uniformed soldiers arrived at the Capitol on Monday in an extraordinary show of force.

Though the Secret Service has primary authority to coordinate security planning during an inauguration and the events surrounding it, the homeland security chief plays an important role, especially in emergencies.

The secretary has the authority to demand resources in an emergency, and in past inaugurations and major-security events has intervened to keep the many federal agencies working together if disputes or other problems arise.

An inauguration is already an all-hands-on-deck affair in Washington, with officers surveilling train stations, canine teams inspecting the inauguration route for explosives, counter-snipers manning rooftops and police officers checking and securing manhole covers to prevent people from sneaking closer to the inaugural activities.

But the siege at the Capitol has put Secret Service planners and their federal partners in feverish reassessment mode to consider all of the ways they can mitigate anything like a repeat.

Rep. Bennie Thompson (D-Miss.), chairman of the House Homeland Security Committee, called Wolf’s decision to step down Monday “questionable.”

“He has chosen to resign during a time of national crisis and when domestic terrorists may be planning additional attacks on our government,” Thompson said in a statement. “Unlike others, he is apparently not leaving the Trump Administration on principle.”

“The Trump Administration too often used the Department as a political weapon, left countless senior leadership positions vacant, and let morale suffer,” Thompson added. “Our homeland security has diminished as a result.”

Trump installed Wolf as acting secretary more than a year ago, after the resignation of Kevin McAleenan, who also served in an acting role. Trump, who repeatedly said he prefers leaving Cabinet members in “acting” roles because it makes it easier for him to remove them, finally nominated Wolf in August, but his confirmation went nowhere, despite Republicans’ control of the Senate.

But the nomination came after a Government Accountability Office report that found Wolf’s appointment had violated the Federal Vacancies Reform Act, because Wolf had not been properly designated in the DHS order of succession following Trump’s removal of then-Secretary Kirstjen Nielsen in April 2019.

In recent months, opponents of the Trump administration’s immigration restrictions have successfully challenged several DHS policy changes on the grounds that Wolf lacked the legal authority to implement the policies. In the most recent setback to Trump, a federal judge in California blocked new measures restricting asylum protections, citing previous rulings that Wolf was not legally appointed to lead the department.

Wolf’s qualifications to lead DHS were often questioned by his critics. He was a lobbyist for the travel industry before joining the Trump administration and working as chief of staff for the Transportation Security Administration. When Trump made Nielsen DHS secretary, Wolf served as her chief of staff and became one of her most trusted aides.

Though he had a reputation as a moderate Republican before joining the administration, Wolf became one of Trump’s most loyal Cabinet members during the government’s forceful response to racial justice demonstrations last summer. In Portland, Ore., where crowds targeted a federal courthouse in nightly protests that repeatedly turned violent, Wolf deployed tactical officers from the U.S. Border Patrol and Immigration and Customs Enforcement (ICE) to make arrests, tactics that were widely criticized as heavy-handed.

Wolf remained defiant, even as former DHS secretaries warned that he was turning the department into a partisan tool of the White House.

Wolf did not respond to inquiries Monday, but he told DHS staff in his statement that the department “has positioned itself for an orderly and smooth transition to President-elect Biden’s DHS team.”

“Welcome them, educate them, and learn from them,” he added. “They are your leaders for the next four years — a time which undoubtedly will be full of challenges and opportunities to show the American public the value of DHS and why it is worth the investment.”

Biden has named Alejandro Mayorkas, who served as DHS second-in-command during President Barack Obama’s second term, as his pick for the secretary role. The Cuba-born Mayorkas would be the first immigrant, and the first Hispanic, to lead DHS, which has 240,000 workers and a $50 billion annual budget.