Secretary of Homeland Security Janet Napolitano is leaving President Obama’s Cabinet, resigning during a fierce immigration debate to become the next president of the University of California system.

“After four-plus years of focusing on these [security] challenges, I will be nominated as the next president of the University of California to play a role in educating our nation’s next generation of leader,” she said. “I thank President Obama for the chance to serve our nation during this important chapter in our history, and I know the Department of Homeland Security will continue to perform its important duties with the honor and focus that the American public expects.”

Napolitano, the former Democratic governor of Arizona, has been in the top security post since the start of Obama’s presidency. The timing of her departure puts the administration in an awkward position because it will lose one of its most vocal advocates for immigration reform — and staunchest defenders of Obama’s commitment to securing the border.

“Since day one, Janet has led my administration’s effort to secure our borders, deploying a historic number of resources, while also taking steps to make our immigration system fairer and more consistent with our values,” Obama said in reaction to the announcement. “And the American people are safer and more secure thanks to Janet’s leadership in protecting our homeland against terrorist attacks. I’ve come to rely on Janet’s judgment and advice, but I’ve also come to value her friendship.”

Napolitano is expected to leave the department in September to head the nation’s largest public university system.

Obama is still awaiting confirmation for his nominees to lead the Environmental Protection Agency and Labor Department, and Napolitano’s exit will give him yet another vacancy to fill at a critical point for his second-term agenda.

For their part, some Republicans jumped on the timing of Napolitano’s announcement.

“Well, that’ll be fun. A new DHS Secretary in the middle of the immigration debate,” quipped Brendan Buck, a spokesman for House Speaker John Boehner, on his Twitter account.