LIMA, Peru (AP) — Venezuelan President Nicolás Maduro was not invited to a summit of Western Hemisphere leaders in June. But by October, he traveled to Egypt for a conference where he joked with French President Emmanuel Macron and shook hands with John Kerry, the U.S. government’s climate envoy.

The encounters, with a towering Maduro graciously smiling throughout, were carefully captured on video, posted on social media and broadcast on Venezuela’s state television.

A few months short of a decade since he inherited the country’s leadership upon the death of President Hugo Chávez, Maduro is working to regain the international recognition he lost when his 2018 re-election was deemed a sham by dozens of nations.

Those efforts are also aimed at bolstering his strength at home as he enters 2023 while pressure mounts for a free and fair presidential election the following year.

Crucial to Maduro’s calculations are his country’s top asset — oil — and the war in Ukraine. The South American country has the world’s largest proven oil reserves, but it has not supplied the West’s market since the U.S. imposed crippling economic sanctions as democracy and human rights deteriorated after Maduro’s re-election.

The international community wants “some kind of contribution to global energy security, and with Russian oil off the market, Venezuelan oil becomes attractive again,” said Ryan Berg, director of the Americas program at the Center for Strategic and International Studies, a Washington-based think tank.

Maduro’s attempt to clean up his image comes as many of the conditions that turned him into an international pariah remain unchanged.

Independent experts working with the U.N.’s top human rights body have documented a systemic attack on government opponents, journalists and others. Their report in September alleged Maduro personally ordered the detention of government opponents, who endured electric shocks, asphyxiation and other cruel acts while in custody.

An economic crisis that began during Chávez’s last months in office has only worsened during Maduro’s presidency. It has driven roughly 7 million Venezuelans to leave the country, made the local currency worthless and pushed millions into poverty.

Under Maduro, who succeeded Chavez in 2013, about three-quarters of the population lives on less than $1.90 a day — the international benchmark of extreme poverty. Power outages are part of everyday life, and water supply is severely restricted.

“He’s trying to project an image of strength, but the reality is that he’s just incredibly thirsty right now for international attention,” said Geoff Ramsey, director of Venezuela research at the U.S.-based Washington Office on Latin America think tank. “We saw this from Cairo, where he was ambushing world leaders and then projecting these hallway encounters as if they were official state visits.”

Maduro has serious cashflow problems and wants access to the international financial system and the U.S. oil market, Ramsey said. But, he added, the only way Maduro likely will get access to dollars again is by engaging in negotiations with the opposition.

Talks between Maduro and the opposition, including the faction backed by the U.S. government, were suspended for more than a year after one of his key allies was extradited to the U.S. from Africa.

But both sides reached a significant agreement to fund much-needed social programs in late November.

The agreement will result in a United Nations-managed fund to finance health, food and education programs in Venezuela.

The money will be drawn from the country’s assets frozen abroad, and it is not expected to go directly to Maduro’s government. But that hasn’t stopped his administration from promoting the deal as a recovery of funds “kidnapped” by the U.S.

Still to be agreed on, though, are the conditions for the presidential election that is supposed to be held in 2024, the release of political prisoners and an end to prohitions on many opposition politicians running for office.

The opposition plans to hold primary elections next year. Its clearest potential candidate is Juan Guaido, though his support within and outside Venezuela has plummeted since he declared himself a rival president to Maduro in 2019 while heading the then opposition-dominated congress and drew tens of thousands of anti-Maduro protesters to the streets.

There have beeen gains for Maduro.

A longtime supporter of Venezuela’s opposition — the government in neighboring Colombia — is now headed by that country’s first leftist president, Gustavo Petro. After taking office earlier this year, Petro immediately moved to restore relations with Venezuela. In a couple of weeks, Maduro will also regain the recognition of Brazil, as signaled by President-elect Luiz Inácio Lula da Silva.

Berg said the region appears to be moving on from its anti-Maduro stance “mostly because of the governments that recent elections have brought to power.”

He said some governments are working under the assumption that Venezuela’s “democratization is going to be a long process,” involving negotiations, multiple elections and sanctions relief, as opposed to a change at a “one discrete point in time.”

“It seems to me like the region is much ready, much more disposed now, to try that method,” Berg said, noting that many nations in the region are struggling with their own domestic problems.