BOGOTA, Aug 7 (Reuters) - Gustavo Petro on Sunday became Colombia's first leftist president, pledging to unite the polarized country in the fight against inequality and climate change and achieve peace with leftist rebels and crime gangs.

Petro, a former member of the M-19 guerrilla group, was sworn in by Senate President Roy Barreras in Bogota's Bolivar Plaza on Sunday afternoon, watched by some 100,000 invitees including Spanish King Felipe VI, at least nine Latin American presidents and other Colombians invited by Petro.

"I do not want two countries, just as I do not want two societies. I want a strong, just and united Colombia," an emotional Petro said in his inauguration speech. "The challenges and tests that we have as a nation demand a period of unity and basic consensus."

Petro has promised to revive scuppered peace negotiations with the National Liberation Army (ELN) rebels and apply a 2016 peace deal to ex-members of the FARC guerrillas who reject it.

His foreign minister has said the government will hold dialogue with gangs and potentially give members reduced sentences in exchange for information about drug trafficking.

Armed groups should accept that deal, Petro said.

"We call on all those who are armed to leave their arms in the haze of the past. To accept legal benefits in exchange for peace, in exchange for the definitive non-repetition of violence," Petro told the cheering crowd gathered under a bright Andean sun.