Mexico's trade deficit shrank to $762 million in July, the government said on Thursday, but it was still higher than expected.

Analysts surveyed by Reuters had forecast the monthly trade deficit at $500 million, compared with an $827 million deficit in June.

Exports rose 14.1 percent year on year, of which non-oil exports increased 13.2 percent, the government said.

Imports in July rose 15.8 percent over the same month a year ago. Of that total, intermediate imports climbed 16.4 percent, imports of consumer goods rose 17.1 percent and capital goods imports increased 10 percent.