WASHINGTON — The United States and Canada are aiming to reach a deal by the end of the week that keeps the three-country North American Free Trade Agreement intact, as President Trump and Prime Minister Justin Trudeau of Canada expressed optimism that the two countries could resolve their differences.

“I think Canada very much wants to make a deal,” Mr. Trump said from the Oval Office on Wednesday, sounding far more optimistic than just days before, when he announced a deal with Mexico and threatened to leave Canada behind.

“Right now we call it the U.S.-Mexico trade agreement and we’ll see whether or not Canada gets into it,” the president said. “I think it’s probably not going to be good at all if they don’t.”

Mr. Trump, who has had frosty relations with Mr. Trudeau since a falling-out in June, said the two had spoken by phone. “Hey, he called me,” Mr. Trump said. “I didn’t call him.”