Australian police said Tuesday they thwarted a terrorist plot in which extremists with ties to an al-Qaida-linked Somali Islamist group planned to invade a military base and open fire with automatic weapons until they were shot dead themselves. Some 400 officers from state and national security services took part in 19 raids on properties in Melbourne, Australia's second largest city, before dawn Tuesday, arresting four men and detaining several others for questioning, police said. Australian Federal Police Acting Commissioner Tony Negus said the raids followed a seven-month surveillance operation of a group of people with alleged ties to al-Shabaab, an Islamist organization fighting to overthrow Somalia's Western-backed transitional government. "Police will allege that the men were planning to carry out a suicide terrorist attack on a defense establishment within Australia involving an armed assault with automatic weapons," Negus told reporters. "Details of the planning indicated the alleged offenders were prepared to inflict a sustained attack on military personnel until they themselves were killed," he said. Australian Prime Minister Kevin Rudd said the plot underscored that Australia is still under threat from extremist groups enraged that the country sent troops to join the US-led military campaigns in Afghanistan and Iraq. "There is an enduring threat from terrorism at home here in Australia as well as overseas," Rudd told reporters in the northern city of Cairns. "This is a sober reminder that the threat of terrorism to Australia continues." Rudd said authorities had advised him it was not necessary to raise Australia's terrorist alert level as a result of the plot. Police sealed off several houses in Melbourne after the raids and were conducting intensive searches. Forensic officers in protective suits collected samples and searched at least one car parked in a driveway, while uniformed officers interviewed neighbors. Terrorist violence is extremely rare in Australia - the unsolved 1978 bombing near the Hilton Hotel that killed two is the best-known incident - and no attacks have been carried out in the country since the Sept. 11 attacks in the US raised security threat levels worldwide. But dozens of Australians have died in terrorist attacks overseas, mostly in Indonesia including the 2002 Bali nightclub bombings. The Somali-linked plot is the second major coordinated attack plan exposed in Australia in recent years. Seven men were imprisoned in the past year for involvement in a nascent plot to target thousands of spectators in an attack on major sporting events in Australia. If it had been carried out, the Somali-linked plot could have been "the most serious terrorist attack on Australian soil," Negus said. Holsworthy Barracks on the outskirts of Sydney was one of the group's potential targets, and surveillance had been carried out at other bases, he said, declining to identify them. Negus said some of the suspects had traveled to Somalia "to participate in hostilities" there. All four arrested are Australian citizens of Somali or Lebanese descent aged between 22 and 26, police said. One of the suspects, Nayes El Sayad, 25, was formally charged in Melbourne Magistrate's Court with conspiring with four others to plan a terrorist attack, which carries a maximum penalty of life in prison. Magistrate Peter Reardon ordered him held in custody and to appear again on Oct. 26. Police were granted approval to extend the detention without charge of the three other suspects arrested Tuesday so they could be further questioned. A fifth man, already in custody on an unrelated assault charge, was also being questioned about the plot. Federal police agent David Kinton told the court that police evidence included intercepted phone calls and text messages between the suspects. The Age newspaper reported on its Web site that one of the messages referred to the Holsworthy base, saying: "I stalked around. It is easy to enter." Negus said authorities decided to move against the group after carefully weighing up how advanced their plan was. He said the group was actively seeking a fatwa, or Islamic religious ruling, approving their plans for the Australian attack. Negus did not say whose approval was being sought. Al-Shabaab, which conducts frequent attacks in Somalia, is seeking to overthrow the Horn of Africa nation's government and establish an Islamic state. The group has claimed responsibility for several high-profile bombings and shootings in the Somali capital of Mogadishu, targeting Ethiopian troops and Somali government officials. It has also killed journalists and international aid workers. The US State Department says al-Shabaab has provided a safe haven to al-Qaida "elements" wanted for the 1998 bombings of the US embassies in Kenya and Tanzania. The two groups have long been suspected of working together, but they have not announced a formal alliance. Al-Qaida has operations in North Africa, Yemen and Iraq.