We show that the group Q ⋊ Q + ∗ of orientation-preserving affine transformations of the rational numbers is quasi-lattice ordered by its subsemigroup N ⋊ N × . The associated Toeplitz C ∗ -algebra T ( N ⋊ N × ) is universal for isometric representations which are covariant in the sense of Nica. We give a presentation of T ( N ⋊ N × ) in terms of generators and relations, and use this to show that the C ∗ -algebra Q N recently introduced by Cuntz is the boundary quotient of ( Q ⋊ Q + ∗ , N ⋊ N × ) in the sense of Crisp and Laca. The Toeplitz algebra T ( N ⋊ N × ) carries a natural dynamics σ, which induces the one considered by Cuntz on the quotient Q N , and our main result is the computation of the KMS β (equilibrium) states of the dynamical system ( T ( N ⋊ N × ) , R , σ ) for all values of the inverse temperature β. For β ∈ [ 1 , 2 ] there is a unique KMS β state, and the KMS 1 state factors through the quotient map onto Q N , giving the unique KMS state discovered by Cuntz. At β = 2 there is a phase transition, and for β > 2 the KMS β states are indexed by probability measures on the circle. There is a further phase transition at β = ∞ , where the KMS ∞ states are indexed by the probability measures on the circle, but the ground states are indexed by the states on the classical Toeplitz algebra T ( N ) .