A month after Argentina’s currency devalued by over 20 percent in less than two weeks and interest rates doubled to 40 percent, the International Monetary Fund agreed to lend Argentina $50 billion. The loan – including an additional $5.6 billion from multilateral development banks – was far larger than analysts expected. This massive stand-by agreement – basically a line of credit – offers Argentina secure financing until the end of 2019. The deal should help ward off another speculative attack on the peso. But Argentina’s appeal to the IMF was a worrisome sign for its economic recovery, and a black eye for President Mauricio Macri. After all, though Mr. Macri inherited economic disarray from Cristina Fernández de Kirchner in December 2015, he and his finance minister had consistently denied any plans to request an IMF program.

The peso selloff clearly changed the government’s calculations. On May 9, Mr. Macri went on national television to announce discussions with the IMF, which he characterized as necessary to “avoid a crisis.” Soon after, Finance Minister Nicolás Dujovne traveled to IMF headquarters to negotiate an emergency loan. The negotiations advanced rapidly, with the United States and other major economies immediately backing Mr. Macri’s government. The show of international support stemmed the pressure on the peso.

However, the optics of an IMF program harmed the government’s already declining popularity, and energized the opposition. On May 25, a national holiday that commemorates the start of Argentina’s independence movement, Ms. Fernández de Kirchner’s supporters staged a protest warning that the IMF agreement put “the motherland at risk.” The former president criticized the IMF deal in an op-ed: “There has never been a single country in the world that applied this organization’s programs and has seen an improvement in its economic or social situation,” she said. Argentina’s powerful unions were also displeased. Normally divided between doves and hawks, the fractious labor movement was united by memories of IMF-imposed austerity in 2001. So far, by raising salaries and rolling back several planned labor reforms, the government has staved off a general strike. But the most combative factions in the labor movement appear emboldened by the government’s weakness. Labor leader Hugo Moyano is threatening a truckers strike like the one that crippled Brazil in recent weeks, and demanding a 27 percent wage increase, far above the government’s 20 percent offer.

The IMF has been careful to describe the program as reflecting Argentine priorities, and shown sensitivity to concerns that its programs have historically worsened poverty and inequality. For the first year, the IMF accepted Argentina’s pre-existing deficit target. The program, IMF Managing Director Christine Lagarde said, is “owned and designed” by Argentina, and will “protect the most vulnerable in the population.” But those reassurances have not calmed anxiety in Argentina, where the IMF has a long and checkered history. For Juan Perón, the IMF was the “spawn of imperialism,” and Argentina did not join the fund until after Mr. Perón was deposed in 1955.

Subsequently, it became a repeat customer. Its chronically high inflation, large fiscal deficits and financial instability prompted a series of IMF programs. The most notable IMF intervention in Argentina began after 1991. President Carlos Menem, a heterodox Peronist, had won over Washington by implementing a neoliberal reform program that included privatizations and trade liberalization. To combat inflation, he had pegged the peso to the dollar. The IMF championed Mr. Menem’s agenda, and helped him advance controversial reforms, including to Argentina’s labor code. In 1998, he addressed the IMF board, noting, “We have worked side by side with the IMF… to achieve macroeconomic stability, deepen structural reforms and adopt policies aimed at improving the economic fortunes of the poorest members of society.” Three years later, Argentina was in the midst of its worst economic crisis in history. In 2001, it defaulted on its $132 billion debt, the largest sovereign default in history at the time. Several presidents resigned during the following, chaotic weeks.

For many Argentines, much of the blame fell to the IMF. Indeed, the IMF acknowledged its role in the crisis, stating that it had “remained engaged in a program relationship with Argentina too long, when the policies being supported were inadequate.” Specifically, the IMF said it had continued to back the peg, known as convertibility, even as Argentina’s dollar-denominated debts piled up and its overvalued peso crippled its export sector. In 2001 alone, the IMF had extended $23 billion in loans to Argentina.

Despite the country’s falling out with the IMF, Argentina signed up for another program in 2003. But soon, a devaluation and the commodities boom propelled Argentina to Chinese rates of growth, and it no longer needed an IMF crutch. In 2006, President Néstor Kirchner repaid all debts to the IMF; the $9.8 billion payment drained foreign reserves, but Argentines welcomed the decision. The IMF, Mr. Kirchner had argued, promoted “policies that provoked poverty and pain for the Argentine people,” and most Argentines seemed to agree. Cutting ties to the IMF became a seminal achievement for the Kirchner movement.

The nasty divorce didn’t end there. Starting in 2007, Argentina began manipulating its economic data, and ultimately earned a censure from the IMF for failing to provide credible GDP and inflation figures, the first country to receive that punishment. In 2012, the IMF closed its offices in Buenos Aires.

Under Mr. Macri, relations quickly improved. After years of refusing to participate in the Article IV process – one of only a handful of countries, such as Syria, Libya and Eritrea, that boycotted the reviews – Argentina opened its books to IMF economists. The first Article IV since 2005 gave Mr. Macri strong support: “The new government began an ambitious and much needed transition toward a better economic policy framework,” the IMF concluded, and “important progress has been made.” In March of this year, Ms. Lagarde visited Buenos Aires, where she praised the government’s economic gradualismo, and insisted that Argentina “does not need” an IMF program.

However, shortly after she left, the vulnerabilities of gradualismo became apparent. As emerging markets suffered a speculative attack, prompted by expectations of interest rate hikes in the United States, Argentina’s peso rapidly lost value. Though the strengthening dollar was stressing emerging markets generally, Argentina was particularly exposed; its high level of dollar debt, budget deficit and current account deficit spooked investors.

Suddenly, it was time to test Ms. Legarde’s enthusiasm for Mr. Macri’s reformist government. As analysts studied the Article IV reports for clues to the IMF’s thoughts on Argentina, the government raced to secure a loan. Indeed, the IMF agreed to help. Appreciative of Mr. Macri’s pro-market agenda, and his willingness to accelerate deficit reduction, it offered a monumental, $50 billion bailout, $20 billion higher than market expectations.

But Mr. Macri’s charm was not the only factor. The IMF is atoning for the 2001 crisis. For years, it has emphasized its newfound commitment to balance macroeconomic stability with political realities. For the IMF, the Argentina bailout offers a chance to demonstrate this new approach to the fund’s most skeptical audience.