Since its plans for a trade alliance with the United States were frozen after Trump's election victory, the EU has focused instead on trying to champion open markets and seal accords with other like-minded countries.
The agreement in principle with Mexico follows a deal struck last year with Japan and comes ahead of talks next week with the Mercosur bloc of Argentina, Brazil, Paraguay and Uruguay.
"With this agreement, Mexico joins Canada, Japan and Singapore in the growing list of partners willing to work with the EU in defending open, fair and rules-based trade," said European Commission President Jean-Claude Juncker.
For Mexico, a deal with the EU is part of a strategy to reduce its reliance on the United States, the destination of 80 percent of its exports. That has become more urgent, given Trump's push to rewrite the North American Free Trade Agreement.
The EU and Mexico wanted to update a trade deal agreed 21 years ago that largely covers industrial goods. The new deal adds farm products, more services, investment and government procurement, and include provisions on labour and environmental standards and fighting corruption.
The European Commission said that, under the deal struck on Saturday, practically all trade in goods with Mexico will be duty-free, including for farm products such as Mexican chicken and asparagus and European dairy produce.
The deal will for example cut Mexican tariffs of up to 20 percent on cheeses such as gorgonzola and increase EU pork exports, the Commission said.
It will also allow Mexican companies to bid for government contracts in Europe and EU companies for those in Mexico, including at state level.
Mexican Economy Minister Ildefonso Guajardo said both sides had achieved a major update of their original accord.
"It needed to be more ambitious in the agricultural sector, it needed to be more ambitious in services, it needed to be more ambitious in many of the elements that in the end we managed to agree on after two years of work," he said.
Guajardo said the deal would grant his country better access for products including orange juice, tuna, asparagus, honey, egg white albumin, as well as "equitable access" for meat products.
It is also set to recognise "geographical indications" for certain food and drink, a key EU demand.
Such indications protect agricultural produce - for example, dictating that the term "champagne" can only be used for sparkling wine from northern France.
It was not clear, however, how the divisive issue of "manchego" cheese had been settled. The EU says the term should only apply to sheep's milk cheese from central Spain, but Mexico has its own "manchego" made from cow's milk.
Negotiators from both sides will continue to work on technical details to produce a final text by the end of the year.
(Reporting by Philip Blenkinsop; additional reporting by Dave Graham in Mexico City; Editing by Gareth Jones and Meredith Mazzilli)
By Philip Blenkinsop