The phase diagram of oxygen is investigated for pressures from 50 to 130~GPa and temperatures up 1200 K using first principles theory. A metallic molecular structure with the $P6_3/mmc$ symmetry ($eta^{}$ phase) is determined to be thermodynamically stable in this pressure range at elevated temperatures above the $epsilon$(${O_8}$) phase. Long-standing disagreements between theory and experiment for the stability of $epsilon$(${O_8}$), its metallic character, and the transition pressure to the $zeta$ oxygen phase are resolved. Crucial for obtaining these results are the inclusion of anharmonic lattice dynamics effects and accurate calculations of exchange interactions in the presence of thermal disorder.