WASHINGTON—The House voted against setting new curbs on government spying powers Thursday in a tilt toward national security—and away from privacy rights—following the Orlando shootings.

Voting 198 to 222, the chamber rejected an amendment that would have blocked the government from requiring companies to build backdoor entries into encrypted technology, like iPhones belonging to suspected terrorists. The measure, considered in the debate over the House’s annual military spending bill, also would have required federal authorities to obtain a warrant before searching through a giant collection of emails and phone calls from Americans that are swept up through a program that targets foreigners.

Opponents, largely lawmakers who worry about hurting the ability of the government to keep Americans safe, warned that requiring a warrant in such cases was unworkable. They added it would hamstring agencies like the National Security Agency from searching through any communications of the Orlando nightclub shooter, Omar Mateen, or his wife that may have been collected during surveillance of foreigners. Mateen was an American citizen.

“Limiting access to critical law enforcement tools to stop these plots would directly put Americans in danger,” said Rep. Chris Stewart (R., Utah) during the debate.

Supporters cited constitutional safeguards that protect Americans from unreasonable searches and seizures. They said they weren’t trying to undercut federal authorities, but instead wanted to ensure that the government followed the constitution when obtaining access to the texts, emails and phone calls of Americans.