We present the first cosmological study of a sample of eROSITA clusters, which were identified in the eROSITA Final Equatorial Depth Survey (eFEDS). In a joint selection on X-ray and optical observables, the sample contains 455 clusters within a redshift range of 0.1 < 𝑧 < 1.2, of which 177 systems are covered by the public data from the Hyper Suprime-Cam (HSC) survey that enables uniform weak-lensing cluster mass constraints. With minimal assumptions, at each cluster redshift 𝑧 we empirically model (1) the scaling relations between the cluster halo mass 𝑀 and the observables, which include the X-ray count rate 𝜂, the optical richness 𝜆, and the weak-lensing mass 𝑀 WL , and (2) the X-ray selection in terms of the completeness function C. Using the richness distribution of the clusters, we directly measure the X-ray completeness and adopt those measurements as informative priors for the parameters of C. We validate our cosmology analysis framework using mock data, and then in a blinded analysis of the real data we further validate the joint modeling of the cluster abundance and the weak-lensing mass calibration with a set of consistency tests. After unblinding, we obtain the cosmological constraints Ω m = 0.245 +0.048 −0.058 , 𝜎 8 = 0.833 +0.075 −0.063 and 𝑆 8 ≡ 𝜎 8 (Ω m /0.3) 0.3 = 0.791 +0.028 −0.031 in a flat ΛCDM cosmology. Extending to a flat 𝑤CDM cosmology leads to the constraint on the equation of state parameter of the dark energy of 𝑤 = −1.25 ± 0.47. The eFEDS constraints are in good agreement with the results from the Planck mission, the galaxy-galaxy lensing and clustering analysis of the Dark Energy Survey, and the cluster abundance analysis of the SPT-SZ survey at a level of 1𝜎. Through extensive testing we find that the eFEDS results are robust with respect to the informative priors applied to the parameters of C, the assumed functional form of the mass scaling of the count rate, and the different subsample selections. Our results suggest an X-ray completeness without a significant redshift dependence. No strong evidence of a broken power-law mass scaling of the count rate is supported by the eFEDS sample of galaxy clusters and groups. This work not only presents the first fully self-consistent cosmological constraints obtained in a synergy between wide-field X-ray and weak lensing surveys, but also demonstrates the success of the empirical modeling in X-ray cluster cosmology studies. We provide updated estimates of individual cluster masses.