Nestled between two of Latin America’s powerhouses (Argentina and Brazil) is Uruguay, a country about the size Córdoba. Historically, Uruguay has been a beneficiary of its neighbors’ growth spurts – and a victim of their recessions.

But in recent years, Uruguay has bucked this historical trend, showing a level of economic resilience unique in its history, and unusual globally. Brazil’s economy contracted two years in a row beginning in 2015, while Argentina has suffered recessions in three of the last four years. Throughout, Uruguay’s economy continued to expand; from 2015 to 2018, it grew by 7 percent, compared to 0.8 percent in Argentina and 4.6 percent in Brazil.

That achievement has not gone unnoticed. “Uruguay managed to grow 16 consecutive years… despite being surrounded by economies in recession,” Alicia Bárcena, the head of the UN’s Economic Commission for Latin America and the Caribbean, recognized.

Nevertheless, Brazil’s continued low growth and the worsening Argentine crisis have affected Uruguay’s economy through a “pronounced” decline in Argentine tourists andstagnant exports.

The situation was made worse by Argentina’s black swan primary election August 11. Uruguay’s economy had been expected to grow by 0.3 percent this year, but the currency and debt crises in Argentina following the opposition’s unexpectedly strong showing in the election will deepen the biting recession in Argentina and may push Uruguay into a shallow downturn.

Even so, it is unlikely Uruguay will suffer a crisis remotely like the one convulsing Argentina.

Uruguay’s newfound resilience is not by happenstance.

Since the turn of the century, Uruguayan authorities have combined macroprudential policies, financial reform and diversification of export markets to decouple the country from its crisis-prone neighbors.

Uruguayans are still traumatized by the crisis of 2002, when the contagion from Argentina’s economic meltdown at the end of 2001 spilled over the Río de la Plata, causing the worst economic and social crisis to hit Uruguay since its return to democracy in 1985. By 2003, poverty had more than doubled.

After Argentine authorities imposed capital controls (el corralito) in December 2001, Argentines began to withdraw their savings from Uruguay’s overexposed financial system. By March 2002, Uruguay had lost 12 percent of bank deposits overall. By May of that year, another 12 percent of deposits had been withdrawn.

The sudden loss of deposits raised fears about the solvency of banks, which led Uruguayans to doubt their financial system’s robustness. Fears of a bank run and default were rampant, which led the government to intervene in a number of private bank to avoid a collapse of the financial system. Thanks to an emergency loan from the United States, Uruguay avoided an Argentina-style default. Even still, the country suffered a large devaluation that led a rapid increase in inflation, smashing wages and employment.

In the aftermath, Uruguayans voted the center-left Frente Amplio into power with a majority government, ending the domination of the country’s two traditional parties.

The new Uruguayan authorities made it a priority to shift Uruguay’s economy away from its dependence on its neighbors – especially Argentina – and to bolster reserves to avoid another sudden devaluation and financial crisis.

Two decades after the 2002 crisis, those efforts have shown remarkable results.

In 1998, 47 percent of Uruguayan exports went to Argentina and Brazil; by 2017, the two countries accounted for only 20 percent of Uruguay’s exports. Meanwhile, exports to Asia increased from 11 percent to 34 percent in the same period, largely driven by Chinese demand. This more balanced export portfolio has helped Uruguay weather external demand shocks from its neighbors.

Another area where Uruguay decoupled from its neighbors is in its financial sector. In theearly 2000s, about 20 percent of Uruguayan deposits, mostly in dollars, came from Argentine savers; by 2018, Argentine deposits in Uruguayan banks accounted for only 7 percent of deposits. Overall, deposits by foreigners fell from 15 percent in 2015 to 9.4 percent in 2017. Importantly, the country has more than enough reserves to cover any bank run by foreigner depositors.

Uruguay’s debt profile has also improved, and is much better than Argentina’s, with debt equal to only 48 percent of GDP, a 13-year average maturity, and about one half denominated in local currency.

Uruguay’s success buffering its economy from the region’s tumult is highlighted by its low country risk. Today, Argentina has the world’s second-highest country risk, at over 2,500 basis points – a stratospheric rate that suggests a high risk of default. For its part, Uruguay has one of the region’s lowest risk ratings, at around 170 basis points, and it boasts investment grade status.

As a result, Uruguay has been rewarded with billions of dollars in foreign direct investment. In 2018, it attracted $2.7 billion, while Argentina, an economy ten times its size, attracted $11.9 billion. The recent announcement of a $3 billion investment in a third pulp and paper plant has further boosted Uruguay’s long-term growth prospects.

That said, Uruguay has made less headway decoupling from its neighbors in the tourism sector.

Uruguay’s sandy beaches and seaside resorts, including the famed Punta del Este, are a major tourist destination for Argentines. In 2017, Argentines accounted for 60 percent oftourists visiting Uruguay, and contributed 2.7 percent of GDP. (Tourists from all other countries combined accounted for 1.3 percent of GDP.)

Due to the devaluation of the Argentine peso in mid-2018, Uruguay has become costly for Argentines. That depressed Argentine demand, and because tourism is a major employer in Uruguay, the drop in Argentine visitors worsened Uruguay’s already lackluster employment picture. In June, unemployment stood at 9.8 percent.

Should Argentina’s crisis become severe and prolonged enough, Uruguay’s tourism industry will not be the only victim on the other side of the river.

Uruguay’s economy is already underperforming – a major theme in this year’s highly competitive election, which could see the Frente Amplio end its long run in power. In addition, Uruguay’s massive and growing budget deficit will limit the next government’s ability to cushion the blow from an expected deep Argentine recession in 2020.

For now, Uruguay maintains its investment grade status, but its fiscal troubles have made it more vulnerable to Argentina’s contagion. Should Uruguay delay its fiscal adjustment, it could find itself running short on international confidence. The country has a far deeper stock of good will than Argentina, but the dividends from Uruguay’s hard-earned reputation are not infinite.