Jesus was made to say that by the Gospeller, here is no proof that he actually said that, or indeed anything that is written anywhere (including rhe Apocryphal texts).
The Abrahamic Religions are, after all, about tribes and politics. There must be something in all of them that makes Us good and Them ungood. 'My way or the highway' was not, on the whole, on the pagan agenda.
For the Greeks, for instance, it was assumed that everyone crossed the Styx, was judged by Aecus, Rhadamanthys or Minos, and went to Asphodel, Tartarus or Elysium.
For the Egyptians, everyone had their heart weighed against a feather by Anubis and Thoth.
For the Norse, there would be no doubt that the Valkyries flew over the battlefieds of Troy as they did over the Northland. Achilles, Hector, and Patroclus would feast together as einherjar in Valhalla!
You see, pagans didn't care about what or who you worshipped. As far as they were concerned, you were judged on your deeds in life, and though the gods had different names in dfferent countries, they were all much of a muchness.
Not that the gods were above war and politics. They simply lacked the power to change people and their fates. Only those gods whose right and duty it was to judge the dead could do so, and as long as the dead person honoured their gods, whoever they were, then that was a merit point.
We gave the Abrahamic God too much power, and it causes nothing but trouble.
Live long and prosper.