The Gaussian algorithm for lattice reduction in dimension 2 (under both the standard version and the centered version) is analysed. It is found that, when applied to random inputs, the complexity is asymptotically constant, the probability distribution decays geometrically, and the dynamics is characterized by a conditional invariant measure. The proofs make use of connections between lattice reduction, continued fractions, continuants, and functional operators. Detailed numerical data are also presented.