MEXICO CITY, Dec 1 (Reuters) - Veteran leftist Andres Manuel Lopez Obrador took office as Mexican president on Saturday, vowing to see off a "rapacious" elite in a country struggling with corruption, chronic poverty and gang violence on the doorstep of the United States.

Backed by a gigantic Mexican flag, the 65-year-old took the oath of office in the lower house of Congress, pledging to bring about a "radical" rebirth of Mexico to overturn what he called a disastrous legacy of decades of "neo-liberal" governments.

"The government will no longer be a committee at the service of a rapacious minority," said the new president, who is often nicknamed AMLO. Nor would the government, he said, be a "simple facilitator of pillaging, as it has been." Lopez Obrador later addressed a massive crowd of supporters in the heart of the capital, promising to put Mexico's sizeable indigenous minority first in his drive to root out inequality.

A major challenge facing the new leader is managing relations with Mexico's top trading partner, the United States, after repeated broadsides by President Donald Trump against Mexico over illegal immigrants crossing the U.S. border.

Lopez Obrador repeated he was seeking to contain migration through a deal with Trump and Canadian Prime Minister Justin Trudeau to foster development in Central America and Mexico.

The first leftist to take office in Mexico in a generation also tried to reassure business after markets slumped since the July 1 election on worries about his policies, including the abrupt cancellation of a $13 billion new Mexico City airport.

Lopez Obrador reiterated investments in the country of 130 million people would be safe, and pledged to respect central bank independence. Saying his government would make savings by stopping losses from the public purse into the "sewer of corruption," he promised not to raise national debt or taxes.

But he promised higher wages for the poor and zero tolerance for corruption in his administration.

And in a reference to one of his heroes, the 19th-century Mexican President Benito Juarez, who separated the church and the state, Lopez Obrador said his government would ensure a divide between economic and political power in the country.

Making 16 references to "neo-liberal" policies in his speech, he vowed to abolish the "regime" he said it had created.

He blamed the government of his predecessor, Enrique Pena Nieto, for causing a plunge in oil output by opening the energy industry in Latin America's no. 2 economy to private investment.

Instead, he vowed to ramp up public investment to rescue state oil company Pemex, which is suffering from heavy debts.

Pena Nieto sat impassively two seats to the left of Lopez Obrador during the sustained attack on his economic legacy, at times touching his face, wiping his brow with his hand and taking occasional sips of water.

"There were few signs in AMLO's speech that the full reality of governing has sunk in thus far," said Duncan Wood, director of the Wilson Center's Mexico Institute.

"Markets will be deeply concerned about the future of the energy sector and the overly ambitious infrastructure plans without any way of paying for them," Wood added.

Still, Mexican billionaire Carlos Slim said he was reassured by the speech, responding to reporters that there was "no doubt" Mexico remained a safe place to invest.

"What is needed, as he said, is to generate jobs and combat poverty. The best investment is to combat poverty," he said.

TRUMP FACTOR

Lopez Obrador also reaffirmed plans to create a low-tax special economic zone on Mexico's northern border to act as the "final curtain" to keep Mexicans working inside their homeland.

He said Trump had treated him respectfully since the July 1 election, and thanked U.S. Vice President Mike Pence and Trump daughter Ivanka Trump for attending the ceremony.

Adressing supporters as evening fell in the Zocalo central square, he took part in a ritual with representatives of indigenous groups. One handed him a ceremonial wooden staff as a symbol of power, incense smoke drifting over the stage.

"I no longer belong to myself, I belong to you, I belong to the people of Mexico," Lopez Obrador said near the end of a long speech in which he ran through a list of his plans.

Many of the tens of thousands of supporters in the Zocalo said they had waited years to see the inauguration of the former Mexico City mayor, who was runner-up in the 2012 and 2006 elections.

"I want our country to be better, we have lived so badly," said Josefina Jimenez, 75, saying she was very excited about the change. "Nobody before has paid attention to us."

Some of the toughest challenges Lopez Obrador faces are more severe than when Pena Nieto took office in 2012 vowing to tackle unprecedented violence. Like his predecessor, the new president says security will be his top priority.

More than 25,000 murders, a record, were logged in 2017. Over 10,000 were registered between July and October, the bloodiest four-month period since modern records began in 1997.

Lopez Obrador addressed critics who fear he could change the constitution to stay on longer than his six-year term permits to oversee what he calls the "fourth transformation" of Mexico. He would under no circumstances seek re-election, he said.

Reflecting his austere manner, Lopez Obrador arrived at Congress in a modest white Volkswagen sedan with little visible security, in contrast to the lifestyles of his predecessors.

He has also dissolved the thousands-strong presidential guard that many Mexicans associate with a distant political class, opting instead for a small group of unarmed body guards.

Some have criticizied the move as irresponsible.

In another symbol of change, the doors of what had been the official presidential residence, Los Pinos, were thrown open to public visitors on Saturday. Lopez Obrador has said he will save money by living in more modest confines.

Pena Nieto returned to Mexico from a G20 summit in Argentina on Saturday morning, on the last official flight for his Boeing Dreamliner presidential plane, which Lopez Obrador is selling.