WASHINGTON—One has learned not to pin too many hopes on presidential diplomacy, but Barack Obama’s upcoming visit to Latin America is an opportunity to reshape relations with Brazil.

He will also be visiting Chile and El Salvador. In El Salvador, a courageous center-left president, Mauricio Funes, has pre-empted efforts by his Marxist coalition to push the country toward the (dwindling) camp of Venezuela’s Hugo Chavez. As for Chile, that country is still Latin America at its best. But more transcendent is the relationship with Brazil, which accounts for 40 percent of Latin America’s gross domestic product.

When Obama came to power, he had grand dreams of a strategic alliance with Brazil’s Luiz Inacio Lula da Silva. He was happy to let Brazil take the political, cultural and economic leadership of the southern part of the hemisphere. But Lula subsequently used every opportunity—G-20 summits, negotiations for the purchase of fighter jets from France, peacekeeping in Haiti, the Honduran crisis precipitated by a Chavez ally—to antagonize the United States. Lula’s naive belief that the only way to enhance his country’s status was to embrace Washington’s foes, most notably Iran, cost him leverage in responsible circles.

Since a good part of Latin America was moving away from the coven of left-wing populism, Brazil became awkwardly ineffective as a force for modernization beyond its borders.

On paper, given her background and almost spiritual attachment to Lula, Brazil’s new president, Dilma Rousseff, looked as though she might be even worse in foreign policy. But after assuming power last month, she signaled that she would move away from the excesses of the Lula years not only in domestic policy—for instance, by tackling the fiscal burden and the country’s absurdly high interest rates—but also in foreign policy.

The relationship with the United States has always been difficult. At the turn of the 20th century, Brazil opposed U.S. plans for a hemispherewide customs union and political alliance, arguing that it would lead to an anti-European bloc rather than an integrated hemisphere. Almost a century later, Lula opposed another attempt at creating a free trade area of the Americas, this time arguing that it would serve American interests—despite the fact that 29 other countries supported it. Of course, now that China is Brazil’s primary trading partner—an outcome that would not have taken place if a genuinely free trade area of the Americas had seen the light of day—the South American giant complains that Beijing is undercutting its industrial base.

There are those who say that Brazil’s anti-American complex really got heated just after World War II, when Washington failed to keep its promise to give the Brazilians a permanent seat on the U.N. Security Council as a reward for their support in the fight against the Nazis. Aside from the fact that the Soviet Union and China, two governments endowed with veto power, opposed Brazil’s ambitions at the time, many other factors have contributed to the adversarial relationship. Among them are the nationalistic and statist legacy of Brazilian President Getulio Vargas; Washington’s support for the coup d’etat of 1964; the “nonaligned” policies of the military dictatorship that eventually resulted from that coup; Brazil’s nuclear program in the 1970s; and the defensive mentality of many Brazilian leaders who believe that their country’s ascendancy is only possible in opposition to the United States.

It is too early to tell whether Rousseff will do away with the anti-American complex. But she is well positioned to do so. Coming from the revolutionary left, her credentials are impeccable in the eyes of the powerful political base of her Workers’ Party and beyond. On the right, the influential former President Fernando Henrique Cardoso and others have already overcome the complex.

God knows the United States has done enough to undermine its own status in recent years at a time when others are emerging as potential superpowers. Still, it is nothing short of pathetic to think that Brazil or any other country can accelerate the decline of the United States, or that it can make itself more powerful by acting like a washed-out 1960s lefty. If you want to be a world leader, you need to behave like one.