Right. Anyway, in some cases the "x" is pronounced in Spanish like the English /h/, for example Mexico and Texas. Some people write "Mejico" or "Tejas"; "Mexican" can be writen in Spanish "mexicano" or "mejicano" (the RAE dictionary accepts both forms).
Well, the "x" stands for the native sound similar to English "sh". That sound does not exist in Castilian Spanish, so at the time of the conquest they used the Portuguese convention (shared by modern Catalan, Galician and Basque as well) and wrote it with "x". Still, Spanish-speakers had no way of pronouncing it, so they replaced it with the "kh" sound, which they commonly transcribe as "j". This was pretty much over by the time of independence - the unpronounceable "x" was generally replaced by a "j" (as in Méjico). But at independence they restored the "nationalist" spellings with "x" - hypercorrecting on occasion (there had never been any "x" in Tejas). The Méjico spelling is, at present, only used in Spain (and even there inconsistently). Restoring the spellings, though, did nothing to the fact that they were unpronounceable except by the speakers of native languages. In newly formed words, such as Pemex, Telmex, CEMEX, etc. they pronounce it as spelled: "ks".