Absorbing UV radiation, ozone protects life on Earth and plays a fundamental role in Earth's temperature balance. The formation of ozone occurs through the ternary recombination reaction: O2 + O + M →O3 + M, where M can be N2, O2 or Ar. Here, we developed a theoretical approach capable of modeling the formation of ozone molecules in ternary collisions, and applied it to the reaction with M=Ar because of extensive experimental data available. The rate coefficients for the direct formation of O3 in ternary collisions O+O2+Ar were computed for the first time as a function of collision energy, and thermally-averaged coefficients were derived for temperatures 5-900 K leading to a good agreement with available experimental data for temperatures 100-900 K. The present study shows that the formation of ozone in ternary collisions O+O2+Ar at temperatures below 200 K proceeds through a formation of a temporary complex ArO2, while at temperatures above 1000 K, the reaction proceeds mainly through a formation of long-lived vibrational resonances of O * 3 . At intermediate temperatures 200 K-1000 K, the process cannot be viewed as a two-step mechanism. In addition, it is found that the majority of O3 molecules formed initially are weakly bound.