A decade ago, Myanmar’s generals, setting out to show they were serious about liberalizing after half a century of brutal military rule, made a bold play: They snubbed China, canceling a joint multibillion-dollar dam project, and embraced the West.

In the period that followed, President Barack Obama visited Myanmar twice. He was photographed kissing the cheek of Aung San Suu Kyi, the former democracy activist who later became Myanmar’s civilian leader. He met with former generals, signaling a readiness to open a new chapter with a nation long encumbered by U.S. sanctions.

Then came the exodus of nearly 1 million Rohingya Muslims, driven from their homes by Myanmar’s military in a scorched-earth campaign that drew a Western outcry and charges of genocide. Suu Kyi, a Nobel Peace laureate, led Myanmar’s defense at the International Court of Justice last month; a provisional ruling is expected next week.

China sensed its moment.

As Chinese President Xi Jinping landed in Myanmar on Friday — almost 20 years since his government’s last state visit there — he hoped to send a clear signal that his country is back in the driver’s seat. Having backed Myanmar, also known as Burma, while Western nations recoiled at its actions against the Rohingya, Xi is poised to cash in by reviving stalled strategic projects — notably a Chinese port and special economic zone — that would deepen Beijing’s reach into the Indian Ocean.

The method is a familiar one for Beijing: Where the West is taking a moral stance or retreating, China’s Communist leaders step in with promises, goodies and demands of their own in pursuit of a strategic advantage.

“China is declaring it has regained its position in Burma and repaired its damaged influence,” said Yun Sun, director of the China Program at the Stimson Center in Washington. “This of course has happened in the wake of the Rohingya crisis. Burma is getting a top visit at a time where it has returned to pariah status in the eyes of the rest of the international community.”

An article in the Global Times, China’s state-run nationalist tabloid, put it more plainly, describing Myanmar as briefly “derailed” when it courted the West.

“But after some turbulence, Myanmar realized there were double standards in the approach Western countries had taken on human rights issues and began to turn to China for diplomatic and economic help,” the article said, quoting an expert who described China as “willing to pull Myanmar from the sludge.”

Myanmar’s ruling National League for Democracy (NLD) party, which runs the country with the still-powerful military, has embraced the overture and expressed gratitude for the state visit. As the country prepares for the international court’s provisional ruling, Xi’s visit represents a strong gesture of “moral support,” said NLD spokesman Myo Nyunt.

“We can assume, as a good friend, [China] is coming to us to support us morally,” he said. “We are an Eastern country, as is China, and so they understand our situation more than others do.”

It is a position Myanmar’s generals had hoped to avoid. The military has long been suspicious of China’s role in funding armed ethnic militias in Myanmar’s hinterlands and is wary of over­reliance on its giant neighbor.

Min Aung Hlaing, commander in chief of Myanmar’s military, traveled the world — India, Russia, Serbia, Pakistan, Germany and Austria — in the years after the country returned to nominally civilian rule after 2015, hoping to diversify relationships and inject professionalism into the armed forces. That became harder after the Rohingya crisis led to visa bans and travel restrictions on some in the Myanmar military, also known as the Tatmadaw, including against Min Aung Hlaing.

“Myanmar is just about as nationalist as others in the region,” said Murray Hiebert, senior associate of the Center for Strategic and International Studies’ Southeast Asia program and author of an upcoming book on China and Southeast Asia.

“They don’t want to be a client state of China,” he added. “The Tatmadaw is not impressed with this.”

Randall Schriver, who until last month was the Pentagon’s top official on Indo-Pacific security affairs, said that even in their limited interactions with the Myanmar military, U.S. defense officials “certainly got the message that the [Tatmadaw] wanted an improved relationship with the U.S. and a strong defense relationship.”

The United States “echoed that only as aspirational,” said Schriver, now the chairman of the Project 2049 Institute, an Asia-focused think tank in Arlington, Va., Va

“They would make pretty inspiring presentations to us and were not willing to take any responsibility for the atrocities, explaining them as though they were legitimate counterterrorism operations,” he said in an interview. “It may be the case that this creates some openings for China, but when you weigh policy options and how we should be positioned, it is not in the interest of the U.S. to be glossing over these mass atrocities.”

As Xi landed Friday afternoon in Myanmar’s capital, Naypyidaw, schoolchildren lined the roads, waving Myanmar and Chinese flags, and representatives of ethnic minority groups performed a traditional dance.

During his two-day visit, Xi is expected to push for progress on the China-Myanmar Economic Corridor, a project under China’s Belt and Road Initiative that includes railways, economic zones and other infrastructure, including a deep-sea port at Kyaukphyu on the Bay of Bengal. The port’s location close to major shipping lanes allows China to avoid the more vulnerable Straits of Malacca and gain a foothold in a region of increasing strategic competition.

Xi will meet with both Min Aung Hlaing, the military leader, and Suu Kyi.

Chinese officials have also played up their role in securing an agreement between Myanmar and Bangladesh to repatriate Rohingya refugees more than two years after they were driven into squalid camps. (Very few have taken up the offer.)

On Thursday, Myanmar’s state-run newspaper, the Global New Light of Myanmar, published a commentary by Xi promising to renew “pauk-phaw,” or brotherly, ties with the Southeast Asian country. He wrote of the need to bring more “impetus” to economic cooperation and speed up the Belt and Road projects.

Still, experts say that Myanmar is a long way from a full embrace of China and that Xi’s visit will not gloss over a relationship marred by mistrust, particularly on the part of the military. Activists are planning a protest Saturday outside the Chinese Embassy against what they say is Beijing’s exploitation of their country’s resources.

Suu Kyi’s NLD party, while close to officials in Beijing, is also still largely welcomed by Western nations and maintains close ties to U.S. lawmakers, giving Myanmar options it did not have when the country was under U.S. economic sanctions.

“Myanmar won’t be back in China’s pocket,” said the Stimson Center’s Sun. “The Burmese and the NLD government are using American acquiescence and Chinese desire to gain influence in Myanmar to their own advantage.”

Mahtani reported from Hong Kong. Diamond reported from Yangon, Myanmar.