Light-matter interactions are ubiquitous, and underpin a wide range of basic research fields and applied technologies. Although optical interactions have been intensively studied, their microscopic details are often poorly understood and have so far not been directly measurable. X-ray and optical wave mixing was proposed nearly half a century ago as an atomic-scale probe of optical interactions but has not yet been observed owing to a lack of sufficiently intense X-ray sources. Here we use an X-ray laser to demonstrate X-ray and optical sum-frequency generation. The underlying nonlinearity is a reciprocal-space probe of the optically induced charges and associated microscopic fields that arise in an illuminated material. To within the experimental errors, the measured efficiency is consistent with first-principles calculations of microscopic optical polarization in diamond. The ability to probe optical interactions on the atomic scale offers new opportunities in both basic and applied areas of science.