Two teenage boys have been charged over allegedly preparing a terrorist act and being members of a terrorist organisation, as police warn the threat of a terrorist attack on Australian soil remains “probable”.

The 16-year-olds were arrested allegedly carrying two bayonet-type knives by the joint counter-terrorism team near a Bankstown prayer hall in western Sydney on Wednesday.

Each was charged on Thursday with planning a terrorist act, which carries a penalty of life in prison, and being a member of a terrorist organisation, which carries a penalty of 10 years’ imprisonment, NSW police said.

Police had believed an attack was imminent, New South Wales police Acting Commissioner Catherine Burn told reporters in Sydney.

“We will be alleging that the two 16-year-old boys went to a gun shop in Bankstown and purchased two knives,” she said. “They have then gone from that location, caught a bus to the location in Bankstown where they were arrested and those items were seized.

“We believe the attack was inspired by Islamic State,” Burn added. She declined to confirm reports one was related to a man already in jail convicted of terror offences. “We were well aware of these two 16-year-olds. We have been concerned about them,” she said.

Police laid charges at 5am after holding the boys overnight. The pair is due to appear in Parramatta children’s court later on Thursday.

Burn said the risk of terrorist attack in Australia remained “probable”, and said all members of the Australian community needed to remain vigilant. “We’ve got to remember that our current threat level is probable. It’s there for a reason because that means that there are people, no matter what age unfortunately, who want to do an attack and who can do an attack and they are out there.”

Police praised the joint counter-terrorism team for their actions on Wednesday. “Had we not been in the right place at the right time ... certainly somebody, potentially today, would be, or another day, would be without their life,” Australian federal police deputy commissioner Michael Phelan told reporters.

Phelan said the process of radicalisation, particularly of young people, could happen rapidly, with potential offenders influenced by local radicalisers, foreign websites, social media and events overseas.

“As we have seen before, over the last two years in particular, some of these disrupted plots have happened very, very quickly. They’ve gone from zero to full radicalisation within 48 hours or 72 hours to an event that we’ve had to stop.”