Context. We present an estimation of cosmological parameters with clusters of galaxies. Aims. We constrain the $Omega_m$, $sigma_8$, and $w$ parameters from a stand-alone sample of X-ray clusters detected in the 50 deg$^2$ XMM-XXL survey with a well-defined selection function. Methods. We analyse the redshift distribution of a sample comprising 178 high S/N 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 ($Lambda$CDM) model, the cosmology favoured by the XXL clusters compares well with results derived from the Planck S-Z 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 $sim$10 and become comparable with those from XXL clusters. Combining the two probes allows us to put constraints on $Omega_m$=0.316$pm$0.060, $sigma_8$=0.814$pm$0.054, and $w$=-1.02$pm$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.