By David Ljunggren

OTTAWA (Reuters) - Canada and Mexico agreed to settle a pair of protracted bilateral disputes on Tuesday in the run-up to a U.S. presidential election in November that could shake ties between the three North American nations.

Prime Minister Justin Trudeau said starting Dec. 1, Canada would scrap rules obliging Mexican visitors to obtain visas. The former Conservative government imposed the restrictions in 2009 to stop what it said were bogus asylum claims.

In return, President Enrique Pena Nieto said Mexico would allow expanded imports of Canadian beef starting in October, ending 13 years of restrictions imposed after a case of mad cow disease was discovered in Canada.

The men stressed their desire to deepen ties between the two nations, which along with the United States are members of the North American Free Trade Agreement. Both countries send the vast majority of their exports to their powerful neighbor.

But the future of NAFTA could be uncertain after the U.S. election, which looks set to pit Republican Donald Trump against Democrat Hillary Clinton. Trump says he wants to tear up or renegotiate the deal while Clinton has taken a populist tack on free trade during her campaign.

Trudeau said the importance of ties between Canada and Mexico could not be overstated.

"It is my hope that through meetings like this one, we will be able to further strengthen that relationship in the years ahead," Trudeau said after talks with Pena Nieto.

Canadian officials say privately that the two nations have not done enough to develop commercial and political ties or explain the benefits of free trade to their citizens.

Pena Nieto, making the first state visit by a Mexican President to Canada for 15 years, said the two nations had created a working group to study how to deepen relations.

The two leaders, as well as U.S. President Barack Obama, will meet in Ottawa on Wednesday for a one-day summit.

Trudeau, speaking to reporters, said he and Pena Nieto had talked briefly about the U.S. election and agreed on the need to work with the new president.

"Regardless of the eventual winner, from one administration to the next, there are changes, and there are shifts, but we will engage ... in a positive, thoughtful collaborative way that understands the importance of the North American trilateral relationship," he said.

(Reporting by David Ljunggren; Editing by James Dalgleish)