The bright K1 III–IV star \gamma Cep has been reported previously to have a companion in a \sim 2.5-yr orbit that is possibly substellar , and also has a stellar companion at a larger separation that has never been seen . Here we determine for the first time the three-dimensional orbit of the stellar companion accounting also for the perturbation from the closer object . We combine new and existing radial velocity measurements ( of both classical precision and high precision ) with intermediate astrometric data from the Hipparcos mission ( abscissa residuals ) as well as ground-based positional observations going back more than a century . The orbit of the secondary star is eccentric ( e = 0.4085 \pm 0.0065 ) and has a period P = 66.8 \pm 1.4 yr and a semimajor axis of 19.02 \pm 0.64 AU . We establish the primary star to be on the first ascent of the giant branch , and to have a mass of 1.18 \pm 0.11 M _ { \sun } , an effective temperature of 4800 \pm 100 K , and an age around 6.6 Gyr ( for an assumed metallicity [ Fe/H ] = +0.01 \pm 0.05 ) . The unseen secondary star is found to be an M4 dwarf with a mass of 0.362 \pm 0.022 M _ { \sun } , and is expected to be \sim 8.4 mag fainter than the primary in V and \sim 6.4 mag fainter in K . The minimum mass of the putative planetary companion is M _ { p } \sin i = 1.43 \pm 0.13 M _ { Jup } , the inclination angle of its orbit being unknown . Taking advantage again of the high-precision Hipparcos observations we are able to place a dynamical upper limit on this mass of 13.3 M _ { Jup } at the 95 % confidence level , and 16.9 M _ { Jup } at the 99.73 % ( 3 \sigma ) confidence level , thus confirming that it is indeed substellar in nature . The orbit of this object ( semimajor axis 1.94 \pm 0.06 AU ) is only 9.8 times smaller than the orbit of the secondary star ( the smallest ratio among exoplanet host stars in multiple systems ) , but it is stable if coplanar with the binary .