A density-fragment interaction ͑DFI͒ approach for large-scale calculations is proposed. The DFI scheme describes electron density interaction between many quantum-mechanical ͑QM͒ fragments, which overcomes errors in electrostatic interactions with the fixed point-charge description in the conventional quantum-mechanical/molecular-mechanical ͑QM/MM͒ method. A self-consistent method, which is a mean-field treatment of the QM fragment interactions, was adopted to include equally the electron density interactions between the QM fragments. As a result, this method enables the evaluation of the polarization effects of the solvent and the protein surroundings. This method was combined with not only density functional theory ͑DFT͒ but also time-dependent DFT. In order to evaluate the solvent polarization effects in the DFI-QM/MM method, we have applied it to the excited states of the magnesium-sensitive dye, KMG-20. The DFI-QM/MM method succeeds in including solvent polarization effects and predicting accurately the spectral shift caused by Mg 2+ binding.