(Adds details on GDP, background)
MEXICO CITY, Nov 24 (Reuters) - Mexico's economy contracted 0.3 percent in the third quarter versus the previous three-month period, the first contraction in nearly two years, the national statistics agency said on Friday, after hurricanes and earthquakes pounded the country.
Third quarter gross domestic product grew 1.5 percent in annual terms compared to the same period a year earlier.
Mexico was struck by two devastating earthquakes in September and was also hit by hurricanes that affected the oil industry, putting a dent in economic activity.
This week the central bank trimmed its growth forecast for 2017 to between 1.8 and 2.3 percent.
The seasonally adjusted third quarter contraction was one basis point deeper than preliminary data showed last month, and it took investors by surprise.
"The market was not expecting any change from preliminary numbers," said Continuum Economics, a research firm.
The central bank sees growth of up to 3 percent next year, but is concerned that talks between the United States, Mexico and Canada to renegotiate the North American Free Trade Agreement (NAFTA) could falter, which would further dent economic activity and hurt the peso.
U.S. President Donald Trump has repeatedly threatened to pull out of NAFTA if the treaty is not reworked to better serve U.S. interests, spooking investors and prompting Mexico to try to diversify its trade.
Latin America's second biggest economy is also battling stubbornly high inflation of well above 6 percent, crimping the central bank's room to stimulate activity with lower borrowing costs. (Reporting by Anthony Esposito; Editing by Frank Jack Daniel and Frances Kerry)