Pure Yang-Mills theory is studied by perturbation theory, using an unconventional expansion with a massive free-particle gluon propagator. The exact Faddev-Popov Lagrangian is considered in a generic linear covariant gauge. The Gaussian effective potential is shown to be gauge invariant and minimal at a massive vacuum, providing a variational argument for mass generation. Loop expanding around the optimal massive vacuum, a massive expansion is recovered, yielding dressed propagators that are in very good agreement with the data of lattice simulations in the Landau gauge. No spurious counterterms or parameters are required since all the mass divergences are canceled exactly in the expansion. At one loop, the propagators are analytic functions and can be easily continued to the whole complex plane, predicting the existence of complex poles for the gluon. Because of the finite damping rate, the gluon is canceled from the asymptotic states, yielding a microscopic proof of confinement.
At finite temperature, the same variational argument provides an optimal mass that depends on temperature. A weak first order transition is observed at T_c=255 MeV where the optimal mass is discontinuous. The equation of state is studied and found in good quantitative agreement with the lattice data, from first principles and without any free parameter. The poles of the gluon propagator are studied as functions of temperature and a crossover scenario is found, with a short intrinsic lifetime of the quasi-gluon below T_c and an almost linear damping rate above T_c, as expected by standard perturbation theory in the high temperature limit.