The influence of nonmagnetic disorder on the Ruderman-Kittel-Kasuya-Yosida interaction of magnetic impurities diluted in a disordered metal is considered. Although the average value of the interaction is exponentially suppressed at distances exceeding the mean free path, its root-mean-square (rms) value does not depend on the disorder parameter in the weak-disorder limit and is numerically larger than its amplitude in pure metal. It is shown that with increase of the disorder the quantum interference corrections similar to those responsible for the weak-localization effects become important. These corrections do not change the power-law decay of all the even moments of the interaction, which remains the same as in the pure metal, but make the coefficients attached to these moments increase critically with the disorder. In the region where, due to the quantum corrections, the conductivity sigma differs considerably from its classical Drude value sigma0 so that sigma0 - sigma is similar to sigma, the 2sth moment of the interaction increases with disorder as (sigma0/sigma)8s2. As the higher moments increase much faster than the variance, the rms value alone does not characterize the interaction, in contrast to the weak-disorder limit where all the irreducible even moments of the interaction are of the same order of magnitude as an appropriate power of the variance. The interaction is characterized in this region by a very broad log-normal distribution indicating that the fluctuations may become considerably larger than the typical value of the interaction. The present results have been obtained by extending the field-theoretical technique developed for treating mesoscopic conductance fluctuations to the treatment of thermodynamic quantities, using the results of the one-loop renormalization-group analysis of the generalized nonlinear sigma model in two dimensions and 2 + epsilon expansion for the qualitative description in three dimensions. The limits of applicability of the present approach and the relevance to experiments are discussed.