Abstract. We consider the formation and evolution of the planetary system PSR B1620-26 in the globular cluster M4. We propose that as M4 is a very low-metallicity environment the standard model of planet formation around main-sequence stars through the accretion of gas on to metallic rocky cores should not be applied. Consequently the previously suggested methods for formation are unlikely. We propose that the planet formed through the interaction of a passing star with a circumbinary disc during the common-envelope phase of the evolution of the inner binary. This formation route is favoured by dense stellar systems such as globular clusters.