Tests of Einstein's general theory of relativity have mostly been carried out in weak gravitational fields where the space- time curvature effects are first- order deviations from Newton's theory(1-6). Binary pulsars(4) provide a means of probing the strong gravitational field around a neutron star, but strong- field effects may be best tested in systems containing black holes(7,8). Here we report such a test in a close binary system of two candidate black holes in the quasar OJ 287. This quasar shows quasi- periodic optical outbursts at 12- year intervals, with two outburst peaks per interval(9,10). The latest outburst occurred in September 2007, within a day of the time predicted by the binary black- hole model and general relativity(11). The observations confirm the binary nature of the system and also provide evidence for the loss of orbital energy in agreement ( within 10 per cent) with the emission of gravitational waves from the system(12). In the absence of gravitational wave emission the outburst would have happened 20 days later(13).