A second Algerian man was also detained in the coordinated raids, which began at 6 a.m. in Berlin, Hanover and Attendorn, a town of about 25,000 about an hour’s drive northeast of Cologne, a Berlin police spokesman, Stefan Redlich, said.

The police found two other Algerian men they were seeking — a 31-year-old in Berlin and a 26-year-old in Hanover — but did not take them formally into custody, the authorities said.

All four men are suspected of links to the Islamic State, also known as ISIS or ISIL, and are believed to have been “planning a violent act intended to seriously damage the state,” Mr. Redlich said.