We present a study of the baryonic fraction in galaxy clusters aimed at constraining the cosmological parameters \Omega _ { m } , \Omega _ { \Lambda } and the ratio between the pressure and density of the “ dark ” energy , w . We use results on the gravitating mass profiles of a sample of nearby galaxy clusters observed with the BeppoSAX X-ray satellite ( Ettori , De Grandi & Molendi , 2002 ) to set constraints on the dynamical estimate of \Omega _ { m } . We then analyze Chandra observations of a sample of eight distant clusters with redshift in the range 0.72 and 1.27 and evaluate the geometrical limits on the cosmological parameters \Omega _ { m } , \Omega _ { \Lambda } and w by requiring that the gas fraction remains constant with respect to the look-back time . By combining these two independent probability distributions and using a priori distributions on both \Omega _ { b } and H _ { 0 } peaked around primordial nucleosynthesis and HST-Key Project results respectively , we obtain that , at 95.4 per cent level of confidence , ( i ) w < -0.49 , ( ii ) \Omega _ { m } = 0.34 ^ { +0.11 } _ { -0.05 } , \Omega _ { \Lambda } = 1.30 ^ { +0.44 } _ { -1.09 } for w = -1 ( corresponding to the case for a cosmological constant ) , and ( iii ) \Omega _ { m } = 1 - \Omega _ { \Lambda } = 0.33 ^ { +0.07 } _ { -0.05 } for a flat Universe . These results are in excellent agreement with the cosmic concordance scenario which combines constraints from the power spectrum of the Cosmic Microwave Background , the galaxy and cluster distribution , the evolution of the X-ray properties of galaxy clusters and the magnitude-redshift relation for distant type Ia supernovae . By combining our results with the latter method we further constrain \Omega _ { \Lambda } = 0.94 ^ { +0.28 } _ { -0.32 } and w < -0.89 at the 2 \sigma level .