Our aim is to give a version of the Moser-Trudinger inequality in the setting of complex geometry. As a very particular case, our result already gives a new Moser-Trudinger inequality for functions in the Sobolev space $W^{1,2}$ of a domain in $R^2$. We also deduce a new necessary condition for the complex Monge-Ampere equation for a given measure on a compact Kahler manifold to admit a Holder continuous solution.