In the middle of a brand-new four-lane highway cutting through southern Sri Lanka’s jungle, Vijitha Gamage and his family left large piles of freshly harvested rice paddy to dry on the baking asphalt.

They didn’t need to dodge traffic. On a recent afternoon, the barely used highway built with Chinese money through a rural stretch of the island nation carried more 50-kilogram (110-pound) rice sacks than vehicles. “The road gets really hot, so the rice dries faster,” Gamage said.

The project is one of several in Sri Lanka that offer lessons for countries looking to snag some of the more than $500 billion projected to underpin Chinese President Xi Jinping’s Belt and Road infrastructure initiative. Interviews with the nation’s politicians, government officials and financial experts show that mitigating the risks is key to maximizing opportunities.

When a 25-year civil war ended in 2009, Sri Lanka had little choice but to turn to China. Beijing stepped up aid and arms shipments as the U.S. and Europe withdrew funding, leaving China in position to quickly offer loans and financing.

Many countries in South Asia are in a similar position. Myanmar and Iran were under western sanctions, while extremist violence has kept investors away from Afghanistan, Pakistan and Bangladesh.

“No one was interested in investing in Sri Lanka,” said Luxman Siriwardena, a former finance ministry official who is now executive director of Colombo’s Pathfinder Foundation, a research group. “Anything is great when there is no alternative.”

Even so, Sri Lanka’s experience came with some costly lessons.

Lesson 1: Too Much Debt Can Backfire

The lure of easy money can tempt politicians to approve expensive projects that generate little economic activity. The sleepy southern district of Hambantota—home to former President Mahinda Rajapaksa—is a case in point.

Aside from the empty four-lane highway, Hambantota boasts an international airport that services one scheduled flight a day, a conference center that is hardly used and a port that handles one ship a day. All were goodies approved by Rajapaksa to benefit his electoral constituency in one of the country’s least developed regions.

The country now spends 80 percent of government revenues paying down what Prime Minister Ranil Wickremesinghe has called “unprecedented” debts. Last year, Wickremesinghe—who took office after Rajapaksa lost the presidency—sold the port to a Chinese firm for $1.1 billion to ease the debt burden.

“If other countries are getting investments, they should not do it the way that we are doing it in Sri Lanka,” said Beragama Wimala Buddhi Thero, the head monk at a local Buddhist temple who worries the new projects will displace villagers. “They should do it in a controlled way. And it should be transparent to the common people.”

Lesson 2: Politicians Will Exploit Anti-China Sentiments

In the 2015 election, Rajapaksa suffered a surprise defeat after challenger Maithripala Sirisena attacked his tight relations with China, warning that Sri Lankans “would become slaves” if the trend continued. Three years later, Rajapaksa’s political group is attacking Sirisena for close ties with China.

“The Chinese are like an octopus—once they get a hold of something, they take everything,” said Ruwan Kumara, a local politician aligned with Rajapaksa who runs a store in Hambantota. “They want to get a hold of all the smaller Asian countries and become the most powerful country in Asia.”

While discontent brews in the countryside, many in the capital benefit from the Chinese cash. Cranes loomed over the skyline in Sri Lanka’s capital, where a $1.4 billion land reclamation project led by state-owned China Communications Construction’s China Harbor Engineering aims to transform Colombo into a “world class” South Asian hub.

“Sri Lanka is smack in the middle” of China’s global infrastructure plans, said Thulci Aluwihare, who left Pricewaterhousecoopers LLP to join the Chinese firm’s local subsidiary. “As a nation, we should take advantage of this capital being exported out of China for infrastructure development. And make use of it.”

Lesson 3: China’s Cash Has a Geopolitical Price

China has said its Belt-and-Road Initiative is a win-win solution that allows it to develop trade routes and export excess capital while building much-needed infrastructure in emerging economies. Yet that hasn’t stopped countries like India—Sri Lanka’s second-largest trading partner—from fearing a potential military component, particularly in Hambantota port.

“Clearly, those of us in the region need to be sensitive to India’s geopolitical interests,” Sri Lankan central bank governor Indrajit Coomaraswamy said in late March at a forum in Colombo. “We in Sri Lanka have learnt the hard way that there are some red lines.”

The prime minister said in a March 26 interview that he’s seeking more foreign inflows from India and Japan amid criticisms of Chinese investment. But in Colombo, others welcome the geopolitical political shift.

With the Asian Development Bank estimating the region needs $1.7 trillion in infrastructure spending annually, Beijing’s spending spree looks like a version of the Marshall Plan, according to Siriwardena, the former Sri Lanka finance ministry official.

“The Marshall Plan was brought in when the Americans wanted to resurrect or reconstruct Europe, but they didn’t do it for nothing—they created a market for themselves, they developed allies,” he said. “We have something like that now.”