Ms. Napolitano, who had been governor of Arizona before being tapped to lead the agency, leaves with a trail of successes, but also has become a lightning rod in the immigration debate which is now raging on Capitol Hill.
"After four plus years of focusing on these 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 leaders," she said in a statement.
Her departure cheered both sides of the immigration debate, with immigrant-rights activists saying she was too harsh in deporting illegal immigrants, and conservative lawmakers saying she failed to secure the borders.
Ms. Napolitano oversaw the deployment and then cancellation of intrusive screening technology at airports under the Transportation Security Administration, which is part of her department. Under her, the Federal Emergency Management Agency also responded to major disasters such as Hurricane Sandy.
But she will be most remembered for her clashes with Congress over immigration, where she has repeatedly said the southwest border is secure and has pressed for legalization of illegal immigrants, battling with lawmakers who say the border isn't secure.
During her tenure, apprehensions of illegal immigrants crossing the border dropped — a signal, she said, that fewer people are even attempting to cross. But her department also stopped using other yardsticks that could have confirmed that information.
She also has set records for deporting immigrants from the U.S., but has tried to strike a balance between immigrant-rights activists and those who want to see a crackdown, by focusing deportations on the most serious criminals, while letting rank-and-file illegal immigrants go free.
Along the way she has left both sides angry, and accusing her of cooking the numbers.
"We are pleased to see her go," said Chris Newman, legal director for the National Day Laborer Organizing Network, which has battled Homeland Security's detention policies and said Ms. Napolitano will be remembered for setting deportation records.
Meanwhile, conservatives attacked her for issuing memos that ordered agents to pick and choose where to enforce immigration laws.
"Secretary Napolitano's tenure at the Department of Homeland Security was defined by a consistent disrespect for the rule of law," said Sen. Jeff Sessions, Alabama Republican.
In a statement, Mr. Obama said she showed extraordinary dedication to her job.
"She's worked around the clock to respond to natural disasters, from the Joplin tornado to Hurricane Sandy, helping Americans recover and rebuild," he said. "The American people are safer and more secure thanks to Janet's leadership in protecting our homeland against terrorist attacks."
Ms. Napolitano is expected to leave the department in early September, according to an administration official.
That will likely set up another controversial nomination battle just as the House is debating immigration bills — and the next nominee will likely have to answer tough questions about how to measure illegal immigration across the southern border.
It could also end up being the first major nomination test under new Senate rules if Democrats move ahead next week with the so-called "nuclear option" to change rules to eliminate filibusters of executive branch appointments.
Ms. Napolitano, who the Drudge Report made notorious by dubbing her "Big Sis," has been a frequent target of attacks from both the right and the left over the TSA's actions.
And her department ignited a firestorm when it signed contracts to buy hundreds of millions of rounds of ammunition, spurring gun-rights activists to accuse her of trying to push up prices for average consumers.
Ms. Napolitano later admitted she had been slow to shoot down the reports because she thought they were so preposterous that nobody would believe them. But members of Congress, whose offices were getting flooded with calls, launched several investigations into the ammunition situation.