Near-critical binary mixtures containing ions and confined between two charged and selective surfaces are studied within a Ginzburg–Landau theory extended to include electrostatic interactions. Charge density profiles and the effective interactions between the confining surfaces are calculated in the case of chemical preference of the ions for one of the solvent components. Close to the consolute point of the binary solvent, the preferential solubility of ions leads to the modification of the charge density profiles with respect to the ones obtained from Debye–Huckel theory. As a result, the electrostatic contribution to the effective potential between the charged surfaces can exhibit an attractive well. Our calculations are based on the approximation scheme that is valid if the bulk correlation length of a solvent is much larger than the Debye screening length; in this critical regime, the effect of charge on the concentration profiles of the solvent is subdominant. Such conditions are met in the recent measurements of the effective forces acting between a substrate and a spherical colloidal particle immersed in the near-critical water–lutidine mixture [Nature, 2008, 451, 172]. Our analytical results are in quantitative agreement with the experimental ones.