The ratio of baryonic to dark matter densities is assumed to have remained constant throughout the formation of structure. With this, simulations show that the fraction
f
gas
(
z
) of baryonic mass to total mass in galaxy clusters should be nearly constant with redshift
z
. However, the measurement of these quantities depends on the angular distance to the source, which evolves with
z
according to the assumed background cosmology. An accurate determination of
f
gas
(
z
) for a large sample of hot (
kT
e
>5 keV), dynamically relaxed clusters could therefore be used as a probe of the cosmological expansion up to
z
<2. The fraction
f
gas
(
z
) would remain constant only when the correct cosmology is used to fit the data. In this paper, we compare the predicted gas mass fractions for both
Λ
cold dark matter (
Λ
CDM) and the
R
h
=
ct
Universe and test them against the three largest cluster samples (LaRoque
et al.
2006
Astrophys. J.
652, 917–936 (
doi:10.1086/508139
); Allen
et al.
2008
Mon. Not. R. Astron. Soc.
383, 879–896 (
doi:10.1111/j.1365-2966.2007.12610.x
); Ettori
et al.
2009
Astron. Astrophys.
501, 61–73 (
doi:10.1051/0004-6361/200810878
)). We show that
R
h
=
ct
is consistent with a constant
f
gas
in the redshift range
z
≲
2
, as was previously shown for the reference
Λ
CDM model (with parameter values
H
0
=70 km s
−1
Mpc
−1
,
Ω
m
=0.3 and
w
Λ
=−1). Unlike
Λ
CDM, however, the
R
h
=
ct
Universe has no free parameters to optimize in fitting the data. Model selection tools, such as the Akaike information criterion and the Bayes information criterion (BIC), therefore tend to favour
R
h
=
ct
over
Λ
CDM. For example, the BIC favours
R
h
=
ct
with a likelihood of approximately 95% versus approximately 5% for
Λ
CDM.