Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

ISLAMABAD, Pakistan — China might just have a new bestie.

The U.S. rival wooed Pakistan with sweet words and hard cash this week, part of a two-way lovefest less about mutual investment than Beijing's deepening ambitions for the region.

“My friend’s lovely image dwells in the mirror of my heart; I tilt my head slightly, and here it comes into my sight,” China's President Xi Jinping proclaimed in an editorial in the Daily Times newspaper at the start of a two-day trip to Pakistan, quoting an Urdu poem. “This will be my first trip to Pakistan, but I feel as if I am going to visit the home of my own brother.”

Xi’s flowery language set the stage for some serious announcements.

During a his visit, the Chinese president and Pakistan's Prime Minister Nawaz Sharif unveiled energy and infrastructure projects worth $45 billion, as well as agreements deepening military cooperation between the two countries.

"Pakistan has been a very solid security partner, but for many years China maintained some distance because of Pakistan's domestic situation."

China has always regarded Pakistan as a strategic partner — namely a bulwark against India — but the trip signaled a serious strengthening of ties between the two nations.

The consolidation of the China-Pakistan partnership is part of what experts have described as Beijing’s “Great Game” strategy, where it aims to bolster its position in Central Asia amid pressure from the U.S. at sea.

“This is not just about the economics of it, rather the strategic imperative of it,” said Sakib Sherani, a former economic adviser to the government who now heads Macro Economic Insights consultancy. “China has big plans for the region, not just Pakistan."

The central plank of Xi's trip was to establish an “economic corridor” linking Gwadar, a port in the south of Pakistan, with China's western Xinjiang region.

The infrastructure revamps — which include helping upgrade Pakistan’s dilapidated railroad network, and building dams, ports and power stations — are part of China’s plan to create a "Silk Road" of land and sea ties to markets in the Middle East and the rest of Asia. The Silk Road is the ancient name for the ancient trade route from China, India, ancient Persia, Africa and Europe.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Along with trade and infrastructure deals, China and Pakistan also announced they were boosting military ties.

Beijing, already struggling with a Muslim separatist movement in Xinjiang, is looking to help Pakistan quell its own militant groups that could team up with Chinese ones.

Pakistan's President Mamnoon Hussain, left, conferring the country's highest civil award "Nishan-i-Pakistan" on Chinese President Xi Jinping, right, at Presidency in Islamabad. AFP - Getty Images

After several terrorist attacks and abductions targeting Chinese citizens in Pakistan, Beijing was also keen to ensure the safety of the laborers working on the slew of projects unveiled during the meeting.

"Our cooperation in the security and economic fields reinforce each other, and they must be advanced simultaneously," Xi said during an appearance with Sharif on Monday.

This is not a trivial point: Not only is the port of Gwadar located in Pakistan’s Balochistan province, which has been rocked by a separatist insurgency for years, militants have killed tens of thousands throughout the country in the last decade.

Chinese Pres vowed to stand by Pak in all its endeavours,continue to support it in fight vs terror,bring stability-3 pic.twitter.com/sH4lCDIhML — AsimBajwaISPR (@AsimBajwaISPR) April 20, 2015

So the decision to take a measured security risk and invest so heavily in Pakistan marked an "important turnaround" for Beijing policy, according to Professor Zhu Feng, a leading international security scholar at Peking University.

"Pakistan has been a very solid security partner, but for many years China maintained some distance because of Pakistan's domestic situation,” he said. “We are very scared of instability. But China has realized that for a stabilizing Pakistan, China's economic engagement is very necessary."

Obviously aware of China’s security fears, Pakistan was anxious to assure Beijing they were on top of the security situation.

"I assured President Xi that Pakistan considers China's security as important as its own security," Sharif said on Monday.

Pakistan also announced it would devote a 12,000-man strong force to guard the at least 5,000 more workers expected in Pakistan as the work gains momentum.

China's move to step up its presence in the region comes after the U.S. administration announced a "pivot" to Asia — but it doesn't necessarily mean the rivals will be in direct competition.

"What we're seeing is an informal division of labor between Beijing and Washington when it comes to Pakistan," Arif Rafiq, adjunct scholar at the Washington-based Middle East Institute said. "Beijing is providing assistance of a strategic nature to Islamabad, investing in big ticket energy and infrastructure projects and aiding Pakistan's military modernization.

"Washington will continue to be a tactical partner for Islamabad, providing it with funding and material vital to fighting a prolonged counterinsurgency against the Pakistani Taliban," Rafiq added.

However, China only has to look at the U.S.’s experience with Pakistan to see that even the most well-laid plans can go awry. Washington poured more than $30 billion of mostly military aid into the country — a key ally — after the 9/11 attacks on the U.S., but violence has continued unabated.

So Islamabad still must make good on its promises to safeguard Chinese workers and the vast infrastructure projects being planned, according Khurram Husain, business editor for the daily Dawn.

"This is a large and game-changing opportunity that the Chinese are offering,” he said. “It's also up in the air whether Pakistan can get its house in order to be ready for embracing this opportunity."

— NBC News' Eric Baculinao and Reuters contributed to this report.