By David Lawder

MEXICO CITY (Reuters) - U.S. Treasury Secretary Jack Lew said on Thursday deeper trade ties between the United States and Mexico will help both economies to grow and President Barack Obama's free trade deal will keep them globally competitive.

The United States and Mexico cannot reject globalization despite the stresses it causes some industries, towns and workers on both sides, partly due to automation, said Lew in a speech at a university in Mexico City.

"Rejecting change is not a solution. Isolating economies and people cannot stop technology, and slower growth cannot improve lives," Lew said at the Instituto Tecnologico Autonomo de Mexico (ITAM). "We must win the argument, one that is supported by the facts, that fair trade will grow both of our economies."

There was still enough time to complete work needed for Congress to pass the 12-country Trans-Pacific Partnership before Obama leaves office, he said.

Lew said the TPP deal, which includes Mexico, will build on the lessons learned from the 22-year-old North American Free Trade Agreement by improving labor and environmental standards.

The TPP faces stiff opposition from presidential candidates Donald Trump and Hillary Clinton. The Obama administration and many business groups are pressing to build support in Congress for a vote after the Nov. 8 election.

"The Trans-Pacific Partnership is critical to advancing our regional competitiveness," Lew said. "It will allow our companies greater market access to 300 million consumers."

However, U.S. Senate Majority Leader Mitch McConnell again threw cold water on the prospects for a TPP vote this year, saying in Washington that the trade deal was "politically toxic" but he hoped a serious discussion on trade could begin next year.

Lew, who is winding up a four-day tour of Latin America's four largest economies, also said U.S. cooperation with Mexico on combating financing of terrorism and drug cartels was at an all-time high, but more work was needed to stem a rising flow of heroin and opioid drugs into the United States.

"Our goal is to disrupt and ultimately dismantle the networks that support drug trafficking organizations, in the formal and informal sectors on both sides of the border," he said, adding that there was a strong foundation between the two countries to pursue such criminal enterprises.

(Reporting by David Lawder and Frank Jack Daniel; Editing by Phil Berlowitz and Bernadette Baum)