Let (X, omega) be a compact normal Kahler space with Hodge metric omega. In this paper, the last in a sequence of works studying the relationship between energy properness and canonical Kahler metrics, we introduce a geodesic metric structure on H-omega(X), the space of Kahler potentials, whose completion is the finite energy space E-omega(1)(X). Using this metric structure and the results of Berman-Boucksom-Eyssidieux-Guedj-Zeriahi as ingredients in the existence/properness principle of Rubinstein and the author, we show that existence of Kahler-Einstein metrics on log Fano pairs is equivalent to properness of the K-energy in a suitable sense. To our knowledge, this result represents the first characterization of general log Fano pairs admitting Kahler-Einstein metrics. Wealso discuss the analogous result for Kahler-Ricci solitons on Fano varieties.