BEIJING — President Donald Trump sought to present a united front with Chinese President Xi Jinping following two days of meetings Thursday, despite lingering differences over trade and North Korea.

On trade, Trump criticized the “very one-sided and unfair” trade relationship between the U.S. and China. But he stopped short of castigating Xi, saying he doesn’t blame the country for having taken advantage of the U.S. in the past.

Trump said China “must immediately address the unfair trade practices that drive” what he said is a “shockingly” large trade deficit, along with barriers to market access, forced technology transfers and intellectual property theft. “But I don’t blame China,” he said. “After all, who can blame a country for being able to take advantage of another country for the benefit of its citizens?”

To applause, Trump said: “I give China great credit.”

His Secretary of State Rex Tillerson offered a blunter assessment of China’s trade surplus with the United States, which in October widened by 12.2 percent from a year earlier, to $26.6 billion. The total surplus with the United States for the first 10 months of the year was $223 billion.

“I think the best way to characterize it is that while we appreciate the long hours and the effort that our Chinese counterparts have put into those trade discussions, quite frankly in the grand scheme of a $3- to 500 billion trade deficit, the things that have been achieved are pretty small,” Tillerson told reporters in Beijing.

He said that, that, “in terms of really getting at some of the fundamental elements of why this imbalance exists, there is still a lot more work to do.”

Tillerson also acknowledged that there were differences “tactics and the timing and how far to go with pressure” on North Korea. But he insisted that the two countries were on the same page.

“There is no disagreement on North Korea,” he said.

Trump and Tillerson’s comments came during Trump’s second and final day in China and after lengthy meetings with Xi. The day included announcements that the U.S. and China had signed agreements valued at more than $250 billion for products including U.S.-made jet engines, auto parts, liquefied natural gas and beef.

Such contract signings are a fixture of foreign leader visits to Beijing and are intended to defuse foreign complaints about China’s trade policies.

Trump had made narrowing the multibillion-dollar U.S. trade deficit with China a priority for his administration. During the presidential campaign, he accused China of “raping our country” on trade and pledged to minimize the countries’ trade imbalance.

For his part, Xi promised a more open business environment for foreign companies in China and said his country was committed to further opening its economy to foreign investment.

“China will not close its doors” and will open them “even wider,” he said, pledging that foreign companies in China, including American ones, would find the market “more open, more transparent and more orderly.”

The United States and other trading partners have been pressing Beijing to give their companies more access to its state-dominated economy. But it remains unclear how far China will go to fulfill its pledges. Previous U.S. administrations have hailed market-opening promises only to be left disappointed.

North Korea remained a focus of the talks. Before arriving in China, Trump had delivered a stern message to Beijing, using an address in South Korea to call on China, North Korea’s biggest trade partner, to do more to confront and isolate the antagonistic nation. That included urging China to fully implement U.N. Security Council resolutions aimed at depriving the North’s government of revenue for its nuclear and ballistic missile programs.

Trump on Thursday appeared far more conciliatory, thanking China for its efforts and saying he’d been encouraged by his conversations.

“China can fix this problem easily. And quickly. And I am calling on China and your great president to hopefully work on it very hard,” Trump said. “If he works on it hard it will happen.”

Before the meetings, China rolled out the red carpet for Trump, treating him to an elaborate welcome ceremony on the plaza outside the Great Hall of the People before the leaders turned to their private talks.

Trump looked on approvingly as a Chinese honor guard played the national anthems of both countries, cannons boomed and soldiers marched. He clapped and smiled as children waving U.S. and Chinese flags and flowers screamed and jumped wildly.

Trump said the welcome “was truly memorable and impressive and something I will never forget.”

Trump was also feted at a state dinner that featured a video montage of the president’s visit, as well as footage of his granddaughter, Arabella, the daughter of Ivanka Trump and Jared Kushner, singing a traditional Chinese song in Mandarin.

On Friday, Trump heads to Danang, Vietnam for the Asia-Pacific Economic Cooperation conference — the first of two conferences he’ll attend on his trip to Asia.

While Trump had told reporters he expected to meet with Russian President Vladimir Putin on the sidelines of the conference, Tillerson said the two sides had never agreed to hold a formal one-on-one meeting. He said the two sides were still discussing whether they had “sufficient substance” to talk about.

Associated Press writers Christopher Bodeen in Beijing and Darlene Superville and Ken Thomas in Washington contributed to this report.