JAKARTA (Reuters) - Thousands of people gathered in the Indonesian capital Jakarta on Thursday to mourn the death of former president B.J. Habibie, who came to power as the nation endured a turbulent transition to democracy after former strongman Suharto stepped down in 1998.

The 83-year-old Habibie had been suffering heart failure, his son Tariq Kemal Habibie told Metro TV late on Wednesday.

People lined the streets as the cortege drove through central Jakarta for the state funeral at the Kalibata Heroes Memorial Park, where President Joko Widodo was set to lead the ceremony.

An engineer by training, Habibie succeeded Suharto as third president of the world's fourth-largest nation just months after becoming his deputy, as the country sank into spasms of rioting and economic upheaval following the Asian financial crisis.

Taking over from Suharto, who had ruled the world's most populous Muslim majority country with an iron fist for 32 years, Habibie held power for just 17 months.

It fell to Habibie to oversee unpopular economic reforms prescribed by the International Monetary Fund at the height of the financial crisis, that were needed to bring inflation down from more than 80% and stabilize a rupiah currency after its value had crashed.

Though he was a product of Suharto's "New Order" administration, which gave a strong political role to the military and stifled opponents, Habibie oversaw democratic reforms to free political prisoners and allow press freedom.

In an abrupt change to longheld policy, he also agreed to a referendum for the people of former Portuguese colony East Timor, which had been annexed in 1976 following an invasion by Indonesian troops in December 1975. The referendum in 1999 resulted in a vote for independence and unleashed a wave of violence.

Habibie also eased discriminatory policies against Indonesia's ethnic Chinese minority, including allowing the speaking and teaching of Mandarin and use of Chinese names that was previously discouraged by Suharto.

He was known for his quest to turn Indonesia into a technological powerhouse, including trying to develop a national aircraft industry.

At the hospital shortly after Habibie's demise, President Widodo described him as "the father of technology in Indonesia."

Mahathir Mohamad, prime minister of neighboring Malaysia, posted his condolences on Twitter and said the death of Habibie was a "big loss."

The U.S. White House, in a statement, praised Habibie's "great leadership in preserving Indonesia's unity."

For many ordinary Indonesians, it was the love story behind Habibie's marriage to his late wife, Hasri Ainun Habibie, that most touched their hearts, and was celebrated in two popular movies. Ainun died in 2010.

"His love for his wife was legendary," wrote Kornelius Purba, a senior journalist for the Jakarta Post, in a column on

Thursday.

Habibie leaves behind two sons, neither of whom is involved in politics.

(Reporting by Tabita Diela, Nilufar Rizki and Gayatri Suroyo; additional reporting by Susan Heavey in Washington; Editing by Simon Cameron-Moore and Bernadette Baum)