We build a variational theory of geodesics of the Tanaka-Webster connection ∇ on a strictly pseudoconvex CR manifold M. Given a contact form θ on M such that (M, θ) has nonpositive pseudohermitian sectional curvature (kθ(σ) ≤ 0) we show that (M, θ) has no horizontally conjugate points. Moreover, if (M, θ) is a Sasakian manifold such that kθ(σ) ≥ k0 > 0 then we show that the distance between any two consecutive conjugate points on a lengthy geodesic of ∇ is at most $\pi/(2 \sqrt{k_0})$ . We obtain the first and second variation formulae for the Riemannian length of a curve in M and show that in general geodesics of ∇ admitting horizontally conjugate points do not realize the Riemannian distance.