Malaysian authorities have accused 30 detained opposition members of conspiring to overthrow the government and to revive communist ideologies after the activists were arrested before a banned political rally.

Opposition parties and human rights groups insisted it was a ludicrous accusation aimed at demonising activists planning a massive street demonstration on 9 July to demand greater electoral transparency.

The detention of the 30 and the allegations against them mark an escalation in tensions between the government – dominated for decades by the ruling National Front coalition – and its political rivals before the rally, which could become Malaysia's biggest in nearly four years. It comes before national polls widely expected by mid-2012.

The opposition leader, Anwar Ibrahim, urged police to release the 30, calling the communist claim "a flimsy pretext".

Since Friday, police have detained about 80 people who were distributing political pamphlets, wearing T-shirts that promoted the planned rally or travelling to publicity events in various towns. Some were later released, but police obtained a court order to hold 30 activists for up to a week in northern Penang state.

The state police official, Abdul Rahim Jaafar, said the 30 – who include an opposition member of parliament – were advocates of communist beliefs. He said they were found in a bus with T-shirts bearing the names and images of key figures who waged a communist insurgency that ended in Malaysia decades ago.

The activists are being investigated under a rarely used law that makes it an offence to try to "wage war" against Malaysia's constitutional monarch. They face up to life imprisonment if charged and convicted.

The information minister, Rais Yatim, said authorities needed to take stern action against those involved in the alleged plot, stressing that "communism is outlawed and not recognised in Malaysia", according to the national news agency, Bernama.

A group of independent political activists who are organising next month's opposition-backed rally issued a statement insisting its intention was not to oust the government but to "make the electoral system truly free and fair".

The arrest of the activists showed a "stark and alarming lack of logic and common sense [that] will further tarnish our nation's image," the group added.

The prime minister, Najib Razak, has told Malaysians to avoid what officials would consider an illegal assembly next month, saying it was an opposition scheme to create chaos and undermine the government.

Other cabinet figures made more ominous warnings. The home minister, Hishammuddin Hussein, said he could not rule out arresting rally organisers under a law that allows detention without trial if they threaten public security.

The activists' demands include overhauling voter lists and introducing transparent procedures for ballots to be cast and counted. The opposition has long accused Najib's ruling coalition of manipulating election results to preserve its nearly 54-year rule, but the government says current election laws are fair.