An 18-year-old Sydney man has been charged with planning a terrorism attack and preparing for foreign incursions, with police alleging he was trying to get hold of a gun to carry out an attack in the city.

Tamim Khaja, of Macquarie Park in Sydney's north-west, was arrested in Parramatta by the Joint Counter Terrorism Team on Tuesday morning.

The teenager is expected to appear at Parramatta Local Court on Wednesday.

The ABC understands he was a former student at Epping Boys High School and when he was in year 12 last year, he was investigated by counter-terrorism police after allegedly preaching radical Islam at the school.

NSW Police Deputy Commissioner Catherine Burn said earlier Khaja's arrest had prevented an attack, which was allegedly being planned and was described as "probably imminent".

Australian Federal Police Acting Deputy Commissioner Neil Gaughan said police would allege Khaja was looking for "possible sites in Sydney to undertake a terrorist attack and was making arrangements to acquire a firearm".

Police allege Tamim Khaja was trying to leave the country to join the IS group. ( Facebook )

Deputy Commissioner Burn said Khaja was acting alone in the alleged plot but said he had associations with some people already before the courts.

Police will also allege Khaja was planning to leave the country to go to Syria to join the Islamic State terror group.

Officers said Khaja had been known to police for about a year and had attempted to leave the country to fight with terror organisations overseas in February, but was unable to do so.

His passport was later cancelled.

Acting Deputy Commissioner Gaughan earlier said both offences Khaja had been charged with carry a maximum sentence of life in prison.

Khaja's lawyer Osman Samin earlier said bail would be applied for "in due course".

Authorities said his arrest was not related to raids conducted at properties in Melbourne, which were part of an operation connected to the arrest of five Victorian men who allegedly planned to travel to Indonesia by boat.