IN JUST two months’ time, Portugal’s three-year bail-out programme will end. As recently as last autumn the country’s chances of returning fully to the markets without a safety net seemed remote. But this year there has been a remarkable rally, with bond yields falling to about 4.5% (see chart). New bond issues have been oversubscribed even though the Portuguese government’s credit rating remains poor. Like Ireland in December, Portugal looks set to make an exit without a precautionary back-up line of credit.

Portugal has benefited from a general reappraisal of risk by investors, as angst about the euro zone breaking up has faded and worries about emerging markets have mounted. But the economy is also now offering more promise, even though its performance has been mixed since the election in June 2011 brought in a new right-of-centre coalition government headed by Pedro Passos Coelho.

A recovery got under way in the spring of 2013, but it followed a gruelling recession that was deeper and lasted longer than had been forecast at the time of the bail-out by the “troika” (representing the IMF and the European authorities). Output declined by 5.7% between 2010 and 2013. Unemployment climbed to a peak of 17.6% and would have gone higher but for an exodus of many young people.

Fiscal progress has fallen short of the goals set three years ago. The bail-out plan envisaged an improvement in the structural primary budget balance (ie, before interest and adjusted for the cycle) of ten percentage points of GDP. In fact the improvement between 2010 and 2013 has been about three-quarters of that. Public debt is peaking at almost 130% of GDP rather than the 115% previously expected.

Despite these economic and fiscal setbacks, Portugal has outperformed in tackling its external imbalances. The current account has moved from a deficit of over 10% of GDP in 2010 to a surplus of 0.5% in 2013, the first in two decades. The swing, which was much bigger than expected three years ago, reflects in part the swoon of domestic demand and associated fall in imports. But exports have contributed even more to the trade adjustment as Portugal, which once sent forth great seafaring explorers, has rediscovered markets outside slow-growing Europe.

The headline figures are exaggerated by a surge in energy exports, mainly of fuel, the value of which has doubled between 2010 and 2013 as Galp, a big energy firm, has stepped up its refining activities. Since the crude oil is imported the net effect on the current account is small. But non-fuel goods have also been doing well. Their overall value rose between 2010 and 2013 by 21%, led by a jump in exports beyond the European Union of 51%. Tourists have also been favouring Portugal, with revenues from their visits rising by a fifth since 2010.

The strength of exports is puzzling, given that Portugal has clawed back only some of the competitiveness it lost in the first decade of the euro. One reason may be that the economy is benefiting belatedly from pain in the early 2000s, when Asian competition hurt former mainstays of the industrial economy like textiles. Adjusting to such a shock takes time as new ventures provide fresh sources of growth. An encouraging sign is that firms set up after 2000 contributed a quarter of exports in 2012, according to the Bank of Portugal.

The vitality of the trading sector will be boosted by structural reforms. According to Carlos Moedas, who is co-ordinating the reforms, this part of the adjustment programme is the most crucial, since it offers a way to achieve competitiveness in a currency union.

There are three main objectives: making it easier to set up businesses and tackling court delays that hamper commerce; loosening a labour market notorious for its rigidity; and lightening the burden imposed on market-oriented firms by high charges from the more protected non-traded sector (such as utilities). Altogether 400 measures have been adopted. Though the reforms will take time to bear fruit, they are likely to raise potential GDP by as much as 3.5% by 2020, according to the OECD.

Portugal needs this boost because of two handicaps. One is poor skills, reflecting historical neglect of education: 65% of those aged between 25 and 64 lack a high-school diploma, compared with 25% across the OECD. The other is excessive debt, not just in the public but even more in the private sector, with firms particularly weighed down by too much borrowing. The process of deleveraging still has several years to go and will slow growth.

The condition of banks is another cause for concern. Although Portugal avoided a property boom and bust, its banks became heavily dependent on external funds, with the loan-to-deposit ratio rising to a high of 167%. That has now fallen to 117%, but the banks are still big borrowers from the European Central Bank. And though their capital has been reinforced, the banking sector is expected to stay unprofitable for a fourth successive year in 2014.

Given these vulnerabilities, Portugal would still benefit from a precautionary credit line from the euro zone’s rescue fund. But the German government is reluctant to sanction this. As things stand Portugal seems set to exit its bail-out without the safety net needed by an economy that is in better shape but remains fragile.