Context. We present an estimation of cosmological parameters with clusters of galaxies. Aims. We constrain the Ωm, σ8, and w parameters from a stand-alone sample of X-ray clusters detected in the 50 deg2 XMM-XXL survey with a well-defined selection function. Methods. We analyse the redshift distribution of a sample comprising 178 high signal-to-noise ratio clusters out to a redshift of unity. The cluster sample scaling relations are determined in a self-consistent manner. Results. In a lambda cold dark matter (ΛCDM) model, the cosmology favoured by the XXL clusters compares well with results derived from the Planck Sunyaev-Zel’dovich clusters for a totally different sample (mass/redshift range, selection biases, and scaling relations). However, with this preliminary sample and current mass calibration uncertainty, we find no inconsistency with the Planck CMB cosmology. If we relax the w parameter, the Planck CMB uncertainties increase by a factor of ~10 and become comparable with those from XXL clusters. Combining the two probes allows us to put constraints on Ωm = 0.316 ± 0.060, σ8 = 0.814 ± 0.054, and w = −1.02 ± 0.20. Conclusions. This first self-consistent cosmological analysis of a sample of serendipitous XMM clusters already provides interesting insights into the constraining power of the XXL survey. Subsequent analysis will use a larger sample extending to lower confidence detections and include additional observable information, potentially improving posterior uncertainties by roughly a factor of 3.