U.S. and Canadian officials were nearing a deal late Sunday on rewriting the North American Free Trade Agreement that would resolve thorny disputes involving the car industry and Canadian tariffs on U.S. dairy products, according to people familiar with the discussions.

Trump administration officials told stakeholders over the weekend they were on a path toward reaching their goal of a draft of a trilateral agreement between the two countries and Mexico. They were racing a U.S.-imposed midnight deadline for the talks with...