An attack on a synagogue that left the building in flames has been labelled a terrorist attack by the Prime Minister.