As Rashi wrote, one who serves avodah zarah denies the Holy One, blessed be He, and one who desecrates Shabbat denies His works and the act of Creation. The poskim ruled that even one who desecrates in public for his desire is like a non-Jew for all his laws. The Avnei Nezer asked this and answered according to the sod.