Two New York City men have pleaded guilty to federal charges that they plotted a pressure-cooker bomb attack in the city on behalf of the Islamic State, prosecutors said on Friday.

The men, Munther Omar Saleh, 21, of Queens, and Fareed Mumuni, 22, of Staten Island, were arrested in 2015.

Mr. Saleh searched online for materials needed to build a pressure-cooker bomb and looked at images of city tourist attractions in hopes of carrying out an attack, a federal complaint said. An ISIS fighter gave Mr. Mumuni the go-ahead for a suicide attack against law enforcement officers who were following the men, the United States Attorney’s Office for the Eastern District of New York said in a statement.

A police officer for the Port Authority of New York and New Jersey saw Mr. Saleh walking on and looking around the George Washington Bridge on two consecutive days. The authorities said he was also seen visiting a spy store in Queens and he later searched online for disguises.