Having spent years in Saudi with an almost identical "justice" system it's a bit of both and can get quite confusing -
Physical Acts - If you get caught then you would imagine it's illegal - that one seems simple - however in reality it's not a black/white decision as it depends on who gets caught and how "public" the act was (i.e. was it seen by foreigners or locals etc). If you are a local with some form of high ranking social power due to "who you know" (called
Wasta) then you can get away with illegal things and the more Wasta you have the more illegal things you can get away with, whereas foreigner tourists have an inbuilt amount of Wasta as they are technically a "guest" which is important in Islam so they get more leeway in judicial decisions but will be expelled immediately (within hours) rather than anything more severe (not the same for ex-pats, thats different).
Being Gay - If you are gay, even if you do not practice any homosexual acts whilst in the country, if a local complains to the police that you are gay (maybe they see your phone screensaver is you kissing a man etc) then you can still be arrested. However, as a foreigner again at worst you would only you have the potential to be expelled from the country rather than being given the death penalty, not because your "crime" is lesser than one carried between locals, but mostly due to PR reasons.
So with Middle Eastern culture it is less about Black/White judicial decisions being made around tourists, instead the "rules" become very flexible when the Royal Family/Government need them to be as long as the outcome shows the country in a "good" light.