Context. In April 2004, the first image was obtained of a planetary mass companion (now known as 2M 1207 b) in orbit around a self-luminous object different from our own Sun (the young brown dwarf 2MASSW J 1207334-393254, hereafter 2M 1207 A). That 2M 1207 b probably formed via fragmentation and gravitational collapse offered proof that such a mechanism can form bodies in the planetary mass regime. However, the predicted mass, luminosity, and radius of 2MI207 b depend on its age, distance, and other observables, such as effective temperature. Aims. To refine our knowledge of the physical properties of 2M 1207 b and its nature, we accurately determined the distance to the 2M 1207 A and b system by measuring of its trigonometric parallax at the milliarcsec level. Methods. With the ESO NTT/SUS12 telescope, we began a campaign of photometric and astrometric observations in 2006 to measure the trigonometric parallax of 2M 1207 A. Results. An accurate distance (52.4 +/- 1.1 pc) to 2M1207A was measured. From distance and proper motions we derived spatial velocities that are fully compatible with TWA membership. Conclusions. With this new distance estimate, we discuss three scenarios regarding the nature of 2M 1207 b: (1) a cool (1150 +/- 150 K) companion of mass 4 +/- 1 M-Jup (2) a warmer (1600 +/- 100 K) and heavier (8 +/- 2 M-Jup) companion occulted by an edge-on circumsecondary disk, or (3) a hot protoplanet collision afterglow.