WASHINGTON — Senate Democrats on Thursday blocked for a third time a spending bill to reopen the Department of Homeland Security, insisting that they would not approve the measure without new curbs on immigration enforcement even amid President Donald Trump’s war in Iran.

Twenty days after federal money for the department lapsed, Republicans had sought to pressure Democrats to relent and agree to fund the department without any new restrictions on the agents carrying out Trump’s deportation drive. They argued that the war in the Middle East made it even more important to fund security agencies, including the Transportation Security Administration and the Secret Service.

“Less than half of the Americans who work for the cybersecurity and infrastructure security agency are on the job,” said Sen. John Thune of South Dakota, the majority leader. “The rest have been furloughed, and the agency has had to cancel vulnerability checks on certain infrastructure. Now you’d think that might raise some concern among Democrats, especially given the current threat environment, but apparently it doesn’t.”

But the failed vote showed that Democrats — at least for now — were holding firm in their demands. All but one, Sen. John Fetterman of Pennsylvania, opposed the measure in a 51-45 vote, leaving it short of the 60 votes needed to move ahead.

Instead, Democrats offered their own proposal to fund the department except for Immigration and Customs Enforcement, Customs and Border Protection.