  The bright K1 III-IV star gamma Cep has been reported previously to have a
companion in a 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 and has a
period of 66.8 yr. We establish the primary star to be on the first ascent of
the giant branch, and to have a mass of 1.18 M_Sun, an effective temperature of
4800 K, and an age around 6.6 Gyr (for an assumed metallicity [Fe/H] = +0.01).
The unseen secondary star is found to be an M4 dwarf with a mass of 0.362
M_Sun, and is expected to be about 6.4 mag fainter than the primary in K. The
minimum mass of the putative planetary companion is M_p sin i = 1.43 M_Jup.
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 (95% confidence
level) and 16.9 M_Jup (99.73%, or 3 sigma) thus confirming that it is indeed
substellar in nature. (Abridged)
