When fluctuating fields are confined between two surfaces, long-range forces arise. A famous example is the quantum-electrodynamical Casimir force that results from zero-point vacuum fluctuations confined between two conducting metal plates1. A thermodynamic analogue is the critical Casimir force: it acts between surfaces immersed in a binary liquid mixture close to its critical point and arises from the confinement of concentration fluctuations within the thin film of fluid separating the surfaces2. So far, all experimental evidence for the existence of this effect has been indirect3, 4, 5. Here we report the direct measurement of critical Casimir force between a single colloidal sphere and a flat silica surface immersed in a mixture of water and 2,6-lutidine near its critical point. We use total internal reflection microscopy to determine in situ the forces between the sphere and the surface, with femtonewton resolution6. Depending on whether the adsorption preferences of the sphere and the surface for water and 2,6-lutidine are identical or opposite, we measure attractive and repulsive forces, respectively, that agree quantitatively with theoretical predictions and exhibit exquisite dependence on the temperature of the system. We expect that these features of critical Casimir forces may result in novel uses of colloids as model systems.