Italian police have arrested a 20-year-old Somali man suspected of having been a member of Islamic State and who had threatened to bomb churches in Italy, including St Peter's Basilica in the Vatican.

They told reporters in the southern city of Bari that the man, identified as Omar Moshin Ibrahim, was detained last Thursday and that a magistrate had charged him on Monday with instigating terrorism and supporting terrorism.

Police said Ibrahim was stopped following a month-long surveillance operation as he was about to leave Bari where he worked for a cleaning company.

The investigation, the police officials said, included wiretaps in which Ibrahim was heard telling someone, "Let's put bombs in all the churches of Italy. Where is the largest church? It is in Rome."

In another conversation, they said, he was heard praising those who "killed on the path of Allah" and hailing last week's shooting at the Strasbourg Christmas market in which a gunman killed five people.

Police added that the man used the alias of Anas Khalil and called himself "Yusuf" on social media, and had arrived in Italy in 2016.

He was suspected of having been a militant of Islamic State previously.

Italian police have increased security around churches, including St Peter's, ahead of Christmas, which draws big crowds to the Vatican area.