During a lavish state dinner with Chinese President Xi Jinping in Beijing, President Donald J. Trump called out his host country for “very one-sided and unfair” trade deals over the years, but at the same time, he applauded their business savvy.

“I don’t blame China. Who can blame a country for being able to take advantage of another country for the benefit of its citizens? I give China great credit,” Trump said on Thursday.

But the president turned serious when he announced that 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. Trump, who has accused China of “raping our country” on trade, made narrowing the multibillion-dollar U.S. trade deficit with China a priority for his administration.

Trump’s comments came after announcing new business deals between the United States and Chinese companies, made in between meetings with Chinese President Xi Jinping on his overseas trip. The U.S. and China had signed agreements valued at more than $250 billion for products that included U.S.-made jet engines, auto parts, liquefied natural gas and beef.

Having visited South Korea just before he traveled to China, Trump also urged the Chinese to exert more pressure on neighboring North Korea to abandon its nuclear pursuits.

“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, who has been calling on all countries to stop doing business with Pyongyang.

China’s trade surplus with the United States in October widened by 12.2 percent from a year earlier to $26.6 billion, according to Chinese customs data released Wednesday. The total surplus with the United States for the first 10 months of the year rose to $223 billion.

Xi promised to open more doors for foreign companies in China and described U.S.-China relations as standing at a “new historic starting point.”

“The Pacific Ocean is big enough to accommodate both China and the United States,” Xi stated.