Mexican gross domestic product increased 0.1% in the April-June period from the prior quarter, narrowly averting a recession that would have dealt a major blow to President Andres Manuel Lopez Obrador's pledge to rev up the $1.2 trillion economy.

Mexico still sends 80% of its exports to the United States and U.S. demand for its goods has been one of the few recent bright spots on its cloudy economic horizon.

Domestic demand has been modest, and gross fixed investment and foreign direct investment have fallen, the most recent data shows.

Mexico's main stock index has dropped more than 17% this year, though the peso currency has been stable, bolstered by high interest rates,

Meanwhile, U.S. manufacturing activity slowed to a near three-year low in July while hiring at factories shifted into lower gear, suggesting a further loss of momentum in economic growth early in the third quarter.

That all spells trouble for a country essentially joined at the hip with the United States, and analysts say Mexico's reliance on U.S. demand could aggravate the risk of a full-blown recession in the coming months.

"Export growth has been the most dynamic component of GDP in 2019 without question," said Luis de la Calle, a former Mexican trade official. Without U.S. buyers, Mexico's economy would be facing tougher times than it is already, he said.

Dragged down by mining, construction and energy production, Mexico's industrial output fell 1.6% in the first five months of 2019, versus a year earlier. The only industrial sector bucking the trend was export-oriented manufacturing, which advanced 1.0%.

In dollar terms, exports climbed 4.2% during the first half of 2019 compared with last year, led by robust demand for goods from the automotive and electronic sectors. But the economy as a whole expanded only 0.3% during the first six months of the year.

U.S. President Donald Trump's multibillion-dollar trade war with China has helped propel Mexico to the top of the list of leading U.S. trading partners this year.

The jump came despite threats by Trump to slap tariffs on all Mexican exports if Mexico did not contain increasing illegal immigration to the United States from Central America.

Since then, Lopez Obrador has repeatedly stressed the importance of making Mexico more self-sufficient economically so it cannot be held hostage to threats from abroad.

The left-wing populist, who has only held office since December, surely knows the road to greater self-sufficiency is long and bristling with obstacles, however. And Mexico is still highly vulnerable to the so-called Colossus of the North, as the United States is known by some of its southern neighbors.

"If the slowdown already visible in some U.S. industrial sectors linked to Mexico persists, we'll be seeing adverse effects in the second half of the year," said Jose Luis de la Cruz, chief economist at the IDIC think tank.

FLAGGING DEMAND

Should demand for manufactured goods wane, Mexico will be increasingly dependent on consumer spending, which makes up about two-thirds of the economy, to underpin growth.

Big ticket purchases have been tepid, though, with car sales falling 6.4% in the first six months of the year.

Mexico's Nemak, an auto parts maker that supplies U.S. companies such as Ford Motor Co and General Motors Co, generated 56% of its revenues in North America last year. It is now projecting an 8% drop in sales volume by the end of 2019.

A Nemak spokesman said the company's 2019 revenue forecast was based on the likelihood U.S. sales of light vehicles and their production in North America would fall. Shares in the company have declined more than 44% in the past year.

Automotive goods make up nearly 36% of Mexican manufacturing exports by value, according to the car industry. U.S. consumers absorb three-quarters of Mexican exports of light vehicles, the biggest component of the sector's output.

The probability of a U.S. recession in the next 12 months reached 32.9% in July, up from 12.5% a year earlier, a monthly report by the Federal Reserve of New York showed.

That is the highest level registered since 2007, when the global financial crisis began to take hold. During the ensuing recession, the U.S. economy contracted 2.5% in 2009, but the Mexican economy shrank 5.3%.

Whatever happens in the United States, Lopez Obrador's failure to persuade investors about his own economic vision has been holding back investment at home, said Jorge Sanchez, an economist at Mexico's FUNDEF think tank.

Investor confidence in Mexico has been shaken by some of the decisions made by Lopez Obrador, including pulling the plug on a partly built, $13 billion airport for Mexico City and his retreat from the prior government's opening of the oil and gas industry to private capital.

"Mexico's problem is more of an internal matter than about the United States," Sanchez said.

The government this week signaled it wanted to lift the sluggish economy by unveiling a $25 billion stimulus package.

Proud of its hard-won record of macroeconomic stability, it remains adamant that better times are coming. Finance Minister Arturo Herrera said on Wednesday that, far from slowing, the economy would pick up speed in the second half of the year.

(Reporting by Sharay Angulo; Additional reporting by Abraham Gonzalez; Editing by Dave Graham and Tom Brown)

By Sharay Angulo