Police in Australia have detained five men suspected of planning a series of Christmas Day attacks using explosives, knives and a gun in the heart of the country's second-largest city, officials said Friday.

The suspects were inspired by the Islamic State group and planned attacks on Melbourne's iconic Flinders Street train station, neighboring Federation Square, a fashionable bar and restaurant precinct, and St. Paul's Cathedral, an Anglican church, Victoria state Police Chief Commissioner Graham Ashton said.

He said they had been plotting the attack for three weeks. Prime Minister Malcolm Turnbull said it was one of the most substantial plots that have been disrupted over the last several years.

The arrests came after a truck smashed into a Christmas market in Berlin on Monday, killing 12 people. A manhunt is underway for the person behind that attack, which prompted increases in security around the world.

Two of seven people initially arrested in raids Thursday night and Friday morning in Melbourne — a 26-year-old man and a 20-year-old woman — were released without being charged, police said.

Five men between the ages 21 and 26 remained in custody. Three appeared in a Melbourne court charged with preparing or planning a terrorist attack. They each face a life sentence if convicted.

Hamza Abbas, 21, Ahmed Mohamed, 24, and Abdullah Chaarani, 26, did not enter pleas or apply for bail. They will appear in court next on April 28.

Police said the other two detained will also be charged with preparing a terrorist attack.

Four of the suspects were born in Australia and the fifth was Egyptian-born with Egyptian and Australian citizenship.

The suspects were preparing to use explosives, knives and a gun, Ashton said.

Police believed the threat had been neutralized through the raids on five Melbourne premises, he said.

"Islamist terrorism is a global challenge that affects us all. But we must not be cowed by the terrorists," Turnbull told reporters.

"We will continue to go about our lives as we always have. What these criminals seek to do is to kill. But they also seek to frighten us, to cow us into abandoning our Australian way of life," he added.

Since Australia's terrorist threat level was elevated in September 2014, the government says there have been four extremist attacks and 12 plots foiled by police.

Australian Federal Police Commissioner Andrew Colvin said the plotters had moved very quickly from a plan to develop a capability to attack.

"In terms of events that we have seen over the past few years in Australia, this certainly concerns me more than any other event that I've seen," Colvin said. "We believe that we have removed the bulk of this particular cell, this group."

Victoria state Premier Daniel Andrews said there will be extra police on the streets of Melbourne on Christmas Day to make the public feel safe.

About 400 police officers were involved in the raids.