BERLIN — An Algerian man and a Nigerian man were detained in central Germany on Thursday on suspicion of preparing an attack with a machete and guns, which were confiscated, as about 450 police officers swooped down on 12 locations.

Eleven of the 12 raided sites were in or near the university town of Göttingen, in the state of Lower Saxony; the other was in the northern part of the state of Hesse.

The Algerian, 27, and the Nigerian, 23, whose names were not disclosed, both lived with their families in Göttingen, the authorities said. The city’s police chief, Uwe Lührig, said that live ammunition was found with the weapons and that an attack had been planned. Photographs also showed a machete among the items confiscated.

Neither the police chief nor Boris Pistorius, the interior minister of Lower Saxony, provided additional details. However, the minister said the raids on Thursday represented “a very important success” against terrorism.