We describe a stream-based analysis pipeline to detect gravitational waves from the merger of binary neutron stars, binary black holes, and neutron-star-black-hole binaries within ∼1 min of the arrival of the merger signal at Earth. Such low-latency detection is crucial for the prompt response by electromagnetic facilities in order to observe any fading electromagnetic counterparts that might be produced by mergers involving at least one neutron star. Even for systems expected not to produce counterparts, low-latency analysis of the data is useful for deciding when not to point telescopes, and as feedback to observatory operations. Analysts using this pipeline were the first to identify GW151226, the second gravitational-wave event ever detected. The pipeline also operates in an offline mode, in which it incorporates more refined information about data quality and employs acausal methods that are inapplicable to the online mode. The pipeline's offline mode was used in the detection of the first two gravitational-wave events, GW150914 and GW151226, as well as the identification of a third candidate, LVT151012.