BUENOS AIRES — The last time a US president visited Argentina, he got caught in the maw of a rising leftist movement in Latin America.
In 2005, when President George W. Bush sought to push through a free-trade agreement for the Americas, he was skewered by Hugo Chávez, the Venezuelan leader, in a speech at a soccer stadium. Néstor Kirchner, the Argentine president, lectured Bush about regional policies promoted by the United States that had caused “misery and poverty.’’ And the free-trade accord was ditched.
A decade later the backdrop to President Obama’s visit, which began Wednesday, could not be more different. Chávez and Kirchner are dead, the momentum sapped from their leftist movement, and Argentina’s new center-right government is pursuing cozier ties with Washington.
“This is a historic opportunity for a new relationship, a new chapter,’’ Marcos Peña, the chief of cabinet, said last week.
Obama’s decision to come to Argentina now — straight after his visit to Cuba, where the Communist government is slowly opening to market forces — signals Washington’s backing for a shift to the center, foreign policy analysts say. He may also be seeking to firm up the United States’s position in the region, where China has been establishing a foothold.
“Obama is working like a sort of pendulum,’’ said Carlos Escudé, a foreign policy adviser to the government of President Carlos Saúl Menem in the 1990s. “He’s going to the Communist regime that is transforming itself, and then he’s coming to the new right-of-center regime.’’
Obama’s trip is also a show of support for President Mauricio Macri, who took office in December and has made market-oriented policy changes as he seeks foreign investment to reinvigorate a sluggish economy.
Macri, the scion of a wealthy family and a former mayor of Buenos Aires, is also repositioning Argentina internationally, distancing the country from socialist Venezuela, courting global business leaders, and welcoming his counterparts from Europe and the United States.
These moves reverse the strategy of his predecessor, Cristina Fernández. Her nationalist policies often hindered trade and investment, and she reveled in pitting herself against Argentina’s business establishment and the United States, preferring to cultivate ties with Russia and China.
Obama lavished praise on Macri and said his visit was ‘‘so personally important,’’ even riffing on his boyhood interest in Argentinian literature and culture.
‘‘President Macri is a man in a hurry,’’ Obama said in Casa Rosada, the pink-hued presidential palace. “I’m impressed because he has moved rapidly on so many of the reforms that he promised.’’
Macri was equally effusive about Obama.
‘‘You emerged proposing major changes and you showed they were possible, that by being bold and with conviction, you could challenge the status quo,’’ he said. ‘‘That was also a path of inspiration for what our dear country is now going through.’’
The exchange was a remarkable contrast to the relations between the two countries just a few months ago.
“If anything should befall me,’’ Fernández said in a 2014 speech criticizing a judge in New York who had scolded her government for its behavior in an international debt dispute, “look to the North.’’
Fernández “committed the error of winning political ground domestically at the cost of losing ground internationally,’’ said Dante Caputo, a former foreign minister.
Macri has made counter- narcotics a tenet of his administration. Patricia Bullrich, the security minister, has already been in Washington to meet with officials from the FBI and the Drug Enforcement Administration, and agencies that investigate money laundering revived bilateral cooperation this week after relations had soured under Fernández.
In other areas, Macri moved to end the prolonged debt dispute by reaching an agreement with litigating hedge funds in New York, although the deal still requires approval from the Argentine Senate. He also wants to increase bilateral trade, which has stalled in recent years, and lure US investors to Argentina’s renewable energy sector.
Talks are underway, too, to ease restrictions on Argentines traveling to the United States. And last month, the United States stopped its policy of opposing loans to Argentina from the World Bank.
Many Argentines look favorably toward an era of renewed cooperation with the United States and accompanying market-oriented policies.
“We’ve been in a political cesspit,’’ said María de la Paz Fernández, 67, a janitor who immigrated here from Spain as a child. “People were so disillusioned. I hope this is for the good of the country.’’
Material from the Associated Press was used in this report.