Ten people were arrested in a nationwide swoop codenamed Operation Hashtag, and two more were detained, the justice ministry said.
Justice Minister Alexandre de Moraes said the group of Brazilian nationals, communicating by messaging services WhatsApp and Telegram, discussed attacks and had begun preparations ahead of the Olympics, which start on August 5 in Rio de Janeiro.
“There was an order between them to start training in martial arts and to (obtain) ammunition, weapons with which they could carry out an act,” de Moraes told a hastily called press conference in the capital Brasilia. “This was in progress. One of them had got in contact with an underground weapons site in Paraguay, asking to buy an AK-47” assault rifle, he said.
However, de Moraes said the threat of terrorism at the Rio Olympics, the first ever held in South America, was “very small.”
He described the group as “an absolutely amateur cell” and “disorganised.”
Although some made a declaration of loyalty to the Islamic State organisation, there was no direct contact, de Moraes said.
Not all members of the group had met each other, he said. “Some of them made an oath of loyalty by Internet to the Islamic State, but there was no personal contact by this group with Islamic State by WhatsApp.”
In a statement, the justice ministry said that it had launched “Operation Hashtag to break up a group involved in the promotion of Islamic State and the preparation for carrying out terrorist attacks and other criminal acts.”
About 130 officers took part in the operation in which 10 were arrested and two more temporarily detained, the statement said.
The arrests and 19 searches were conducted in states across the country, ranging from the Amazonas region to the financial capital Sao Paulo and Rio de Janeiro, where the Olympics open on August 5.
Last week, Brazil said it was bolstering security for the August 5-21 Olympics following the truck attack in the French city of Nice, which killed 84 people and left scores badly wounded.
The attack has been claimed by the Islamic State group.
The Brazilian intelligence agency ABIN last month picked up messages in Portuguese that it said were linked to the Islamic State group.
Brazil’s Olympics security plan calls for the mobilisation, starting July 24, of some 85,000 members of the security forces.
These include 47,000 police officers and 38,000 military service members tasked with protecting the 10,500 athletes, and some 500,000 tourists expected to come from all parts of the world.