Greece agreed to take those steps in return for a massive emergency loan from the European Union and International Monetary Fund .