Codon usage bias (CUB) in Drosophila is higher for X-linked genes than for autosomal genes. One possible explanation is that the higher effective recombination rate for genes on the X chromosome compared with the autosomes reduces their susceptibility to Hill-Robertson effects, and thus enhances the efficacy of selection on codon usage. The genome sequence of D. melanogaster was used to test this hypothesis. Contrary to expectation, it was found that, after correcting for the effective recombination rate, CUB remained higher on the X than on the autosomes. In contrast, an analysis of polymorphism data from a Rwandan population showed that mean nucleotide site diversity at 4-fold degenerate sites for genes on the X is approximately three-quarters of the autosomal value after correcting for the effective recombination rate, compared with approximate equality before correction. In addition, these data show that selection for preferred versus unpreferred synonymous variants is stronger on the X than the autosomes, which accounts for the higher CUB of genes on the X chromosome. This difference in the strength of selection does not appear to reflect the effects of dominance of mutations affecting codon usage, differences in gene expression levels between X and autosomes, or differences in mutational bias. Its cause therefore remains unexplained. The stronger selection on CUB on the X chromosome leads to a lower rate of synonymous site divergence compared with the autosomes; this will cause a stronger upward bias for X than A in estimates of the proportion of nonsynonymous mutations fixed by positive selection, for methods based on the McDonald-Kreitman test.