The conjugate point theory of the calculus of variations is extended to apply to the buckling of an elastic rod in an external field. We show that the operator approach presented by Manning (Manning et al . 1998 Proc. R. Soc. A 454 , 3047–3074) can be used when the second-variation operator is an integrodifferential operator, rather than a differential operator as in the classical case. The external field is chosen to model two parallel ‘soft’ walls. We consider the examples of two-dimensional buckling under both pinned–pinned and clamped–clamped boundary conditions, as well as the three-dimensional clamped–clamped problem, where we consider the importance of the rod cross-section shape as it ranges from circular to extreme elliptical. For each of these problems, we find that in the appropriate limit, the soft-wall solutions approach a ‘hard-wall’ limit, and thus we make conjectures about these hard-wall contact equilibria and their stability. In the two-dimensional pinned–pinned case, this allows us to assign stability to the configurations reported by Holmes (Holmes et al . 1999 Comput. Methods Appl. Mech. Eng. 170 , 175–207) and reconsider the experimental results discussed therein.