Answer: Due to regional variations, there aren't any rules that hold true throughout the Spanish-speaking world. In general, however, when between vowels (as in exactamente) the Spanish x is pronounced basically like the English "ks" sound but softer or less explosive. When it comes before another consonant (as in expedición), it has the "s" sound in some areas but the soft "ks" sound in others. In some areas, the letter's pronunciation before a consonant varies from word to word. The only way to know for sure is to listen to someone speaking with the regional accent you wish to emulate.
When a word begins with x (there aren't many such words, and most are English cognates), it is usually given the "s" sound, not the "z" sound of English. Thus a word like xenofobia sounds the same as if it were spelled senofobia.
In some Mexican place names, indeed in the name of México itself, the x is pronounced the same as the Spanish letter j.
Making matters more confusing is that in a few words of Catalan, Basque or indigenous American origin the x is pronounced like the English "sh." This is especially common in southern Mexican and Central American place names. One of the larger cities of Guatemala, for example, is Xela, pronounced something like SHEL-ah.