Definitely "an".
The word X-ray is never pronounced any way other than "exray", and as has been discussed before, the choice of a or an is based solely on pronunciation, regardless of spelling.
Since X-ray is pronounced beginning with a vowel, it must be preceded by an .
english.stackexchange.com/users/48/JSBձոգչ
'an', because how it sounds is what matters.
An interesting example is an hour , et.
al.
The fact that h is not considered a vowel from the article point of view says a lot about English pronunciation.
Another interesting example of article form leaking unusual information, from Life, the Universe and Everything : "I think," said Ford in a tone of voice which Arthur by now recognized as one which presaged something utterly unintelligible, "that there's an SEP over there.
"
It means that the author meant that SEP achronym is to be pronounced 'es ee pee' and never 'sep'.
english.stackexchange.com/users/188/Pavel Radzivilovsky
In this situation you use "an", because phonetically the sound you are making (the X) starts with an "E": you hear "Ex - ray".
This is true of any letter that, when pronounced, sounds like it starts with a vowel, and often you will need to adapt your use of "a" or "an" even for the same letter.
For example: A Nasty cold was going around the office vs
An NHS doctor was the first to diagnose the bug
Phonetically you say "EN AITCH ESS", so you use "An NHS".
Likewise, as you say "EX-RAY", you say, "An X-Ray".
The way the word is pronounced is the key factor here, rather than the spelling.
Edit
: Looks like JSBangs beat me to it :)
english.stackexchange.com/users/3320/Andy F
"An X" is correct, as the pronunciation of the letter X has an initial vowel sound.
english.stackexchange.com/users/1442/xdumaine
The choice of the indefinite article in English is purely phonetically based.
Since the pronunciation of the letter X is headed by a vowel, an is the natural choice.
english.stackexchange.com/users/13637/deutschZuid
I was asking this question on Area 51: "How do I tell if an airport scanner is a X-ray scanner?", but I keep wanting to put an 'an' in front of X-ray because it starts with the 'eh' sound.  So is it 'a' or 'an'?
Does one use 'a' or 'an' before the word X-Ray?
english.stackexchange.com
<indefinite-articles>
english.stackexchange.com/questions/8181
english.stackexchange.com/users/2805/Mark Rogers
The article used before a word is based on pronunciation, regardless of spelling. As a result, the article used in front of X-Ray should be "an". The word  X-ray  is never pronounced any way other than "exray", and as has been discussed before, the choice of  a  or  an  is based solely on pronunciation, regardless of spelling.Since  X-ray  is pronounced beginning with a vowel, it must be preceded by "an". The choice of the indefinite article in English is purely phonetically based.Since the pronunciation of the letter X is headed by a vowel, " an" is the natural choice.  
The article used before a word is based on pronunciation, regardless of spelling. As a result, the article used in front of X-Ray should be "an". An X-Ray because X is pronounced as a vowel. 
Since  the pronounciation of X-ray  begins with a vowel sound, it must be preceded by  "an". "An" is the correct choice here because the pronunciation of "X-ray" starts with an initial vowel sound.
The word  X-ray  is never pronounced any way other than "exray", and as has been discussed before, the choice of  a  or  an  is based solely on pronunciation, regardless of spelling. Since  X-ray  is pronounced beginning with a vowel, it must be preceded by  an . Phonetically you say "EN AITCH ESS", so you use "An NHS". The choice of the indefinite article in English is purely phonetically based. Since the pronunciation of the letter X is headed by a vowel, " an" is the natural choice.  
An X-Ray not  a X-Ray An X-Ray because it phonetically sounds better An X-Ray because X is pronounced as a vowel. 
"An" is the correct choice here because the pronunciation of "X-ray" starts with an initial vowel sound.