Surface gravity is one of a stars basic properties, but it is difficult to measure accurately, with typical uncertainties of 25-50 per cent if measured spectroscopically and 90-150 per cent photometrically. Asteroseismology measures gravity with an uncertainty of about two per cent but is restricted to relatively small samples of bright stars, most of which are giants. The availability of high-precision measurements of brightness variations for >150,000 stars provides an opportunity to investigate whether the variations can be used to determine surface gravities. The Fourier power of granulation on a stars surface correlates physically with surface gravity; if brightness variations on timescales of hours arise from granulation, then such variations should correlate with surface gravity. Here we report an analysis of archival data that reveals an observational correlation between surface gravity and the root-mean-square brightness variations on timescales of less than eight hours for stars with temperatures of 4500-6750K, log of surface gravities of 2.5-4.5 (cgs units), and having overall brightness variations <3 parts per thousand. A straightforward observation of optical brightness variations therefore allows a determination of the surface gravity with a precision of <25 percent for inactive Sun-like stars at main-sequence to giant stages of evolution.