Australian police have arrested four people in the city of Melbourne after uncovering what they say was a plot to launch a suicide attack.
The group was planning to carry out the attack on an army base, police said.
More than 400 officers were involved in searching 19 properties across the city before dawn on Tuesday.
The suspects are Australian nationals of Somali and Lebanese descent; one man, aged 25, has been charged with conspiring to plan a terrorist act.
Nayaf El Sayed, from the Glenroy district of Melbourne, was remanded in custody until 26 October.
He did not enter a plea or apply for bail, and refused to stand for the magistrate in court.
His lawyer told the hearing: "He believes he should not stand for any man except God."
Police were granted extra time to question three others - Saney Aweys, Yacqub Khayre and Abdirahman Ahmed.
A fifth man, who had been detained earlier, was also being questioned about the alleged plot.
"Police believe members of a Melbourne-based group have been undertaking planning to carry out a terrorist attack in Australia and [are] allegedly involved in hostilities in Somalia," a police statement said.
"The men's intention was to actually go into the army barracks and to kill as many soldiers as they could before they themselves were killed," said Tony Negus, acting chief commissioner of the Australian Federal Police.
Holsworthy Barracks on the outskirts of Sydney was one of the planned targets, according to police.
The attack would have been the most serious terrorist attack on Australian soil, Mr Negus added.
"Members of the group have been actively seeking a fatwa or religious ruling to justify a terror attack on Australia," he said.
Prosecutors told the court they had evidence some of the men had taken part in training and fighting in Somalia.
They also said there were phone conversations, text messages and surveillance footage, including footage of one of the suspects outside the Holsworthy army base, linking the suspects to an alleged attack.
The court heard the men planned to seek a fatwa, or religious ruling, to support an attack on the Holsworthy army base.
Australian Prime Minister Kevin Rudd said: "The sobering element of today's development is the reminder to all Australians that the threat of terrorism is alive and well, and this requires continued vigilance on the part of our security authorities."
The country's security level is unchanged at medium, where it has been since 2003.
The police said the raids followed a seven-month operation involving several state and federal agencies.
Police believe those arrested are linked to the Somali-based al-Shabab group, which seeks to overthrow the weak UN-backed Somali government and is believed to have links to al-Qaeda.