Phonological rules can be variable in two ways: they can apply to a subset of the lexicon (lexical variation), or apply optionally, with a probability that depends on the phonological environment (stochastic variation). These two types of variation are occasionally seen as mutually exclusive. We show that the vowel–zero alternation in Russian prepositions ([s trudom] ‘with difficulty’ vs. [sə stinoj] ‘with the wall’) exhibits both types of variation. In two corpus studies and a nonce-word experiment, we document novel stochastic factors that influence the alternation: similarity avoidance, stress position and sonority profile. These constraints interact additively, lending support to a weighted-constraints analysis. In addition to phonologically determined stochastic variation, we find significant lexical variation: phonologically similar nouns differ in the rate at which they condition the alternation in the prepositions. We analyse this pattern by augmenting the weighted-constraints approach with lexical scaling factors.