People going on pilgrimage to Mecca require a visa from the Saudi Government for that purpose. To receive it, you ought to demonstrate you are a Muslim. There are internal border guards in Saudi Arabia who will require documentation if you are travelling.
By the time you get into one of these cities, you'd have had your documentation checked numerous times.