WASHINGTON—Kirstjen Nielsen resigned Sunday as homeland security secretary, adding another challenge for an administration grappling with its core immigration agenda while facing a surge of migrants at the southern border.

Ms. Nielsen met with President Trump and acting chief of staff Mick Mulvaney at the White House on Sunday to discuss immigration and personnel issues, one person briefed on the meeting said. Ms. Nielsen had been blindsided by Mr. Trump’s sudden decision to drop the nomination of Ron Vitiello, a veteran border...