We constrain flat cosmological models with a joint likelihood analysis of a new compilation of data from the cosmic microwave background ( CMB ) and from the 2dF Galaxy Redshift Survey ( 2dFGRS ) . Fitting the CMB alone yields a known degeneracy between the Hubble constant h and the matter density \Omega _ { m } , which arises mainly from preserving the location of the peaks in the angular power spectrum . This ‘ horizon-angle degeneracy ’ is considered in some detail and shown to follow a simple relation \Omega _ { m } h ^ { 3.4 } = { constant } . Adding the 2dFGRS power spectrum constrains \Omega _ { m } h and breaks the degeneracy . If tensor anisotropies are assumed to be negligible , we obtain values for the Hubble constant h = 0.665 \pm 0.047 , the matter density \Omega _ { m } = 0.313 \pm 0.055 , and the physical CDM and baryon densities \Omega _ { c } h ^ { 2 } = 0.115 \pm 0.009 , \Omega _ { b } h ^ { 2 } = 0.022 \pm 0.002 ( standard rms errors ) . Including a possible tensor component causes very little change to these figures ; we set an upper limit to the tensor-to-scalar ratio of r < 0.7 at 95 % confidence . We then show how these data can be used to constrain the equation of state of the vacuum , and find w < -0.52 at 95 % confidence . The preferred cosmological model is thus very well specified , and we discuss the precision with which future CMB data can be predicted , given the model assumptions . The 2dFGRS power-spectrum data and covariance matrix , and the CMB data compilation used here , are available from http : //www.roe.ac.uk/~wjp/ . keywords : large-scale structure of Universe , cosmic microwave background , cosmological parameters