Rahul Gandhi, the scion of Indiainfo-icon's most famous political dynasty, on Saturday took over as president of the main opposition Congress while facing a stiff challenge from Prime Minister Narendra Modi's ruling Hindu nationalists.

Gandhi took the mantle from his mother Sonia Gandhi at a party function at a time when it's losing power to Modi's Bharatiya Janata Party since 2014.

Gandhi's party has suffered humiliating defeats in recent state electionsinfo-icon despite his active campaigning to win back support.

Sonia Gandhi in her speech described her son as a new hope for the Congress as the party workers danced, burst firecrackers and distributed Indian sweets to celebrate the generational shift in the leadership.

Gandhi, 47, will be taking on Modi when the prime minister seeks a second five-year term in 2019. Modi has vowed to create a Congress-free India while working for the rise of Hindu nationalist forces.

Gandhi in his speech described himself as an "idealist" and said Indian people were getting disillusioned by policies pursued by the Modi government.

He said the Congress party, which ruled India for decades, took the country into the 21st century through modernisation and development. He accused Modi of taking India "'to a medieval path where people are butchered because who they are, beaten for what they believe in and killed for what they eat.'" "The Congress will take on this challenge and will never back down," he said.

Gandhi was referring to killings and attacks on minority groups, especially Muslims, since the Bharatiya Janata Party swept national elections in 2014. Most of the violence against Muslims has involved fringe Hindu vigilante groups that have become active in small towns and cities across India. Muslims make up about 14 percent of India's 1.3 billion people and Hindus about 80 percent.

Gandhi is the sixth member of the Nehru-Gandhi family to lead Congress. His father Rajiv Gandhi, grandmother Indira Gandhi and great- grandfather Jawaharlal Nehru have served as prime ministers since India's independence from British colonialists in 1947. Rahul Gandhi entered politics in 2004.

"Today, the Congress faces a possibly existential crisis even as Sonia Gandhi makes way for Rahul Gandhi to head the party,'" said Neerja Chowdhury, a political commentator.

Gandhi was elevated as the party's vice president in January 2013, serving as his mother's No. 2. Sonia Gandhi, 71, stepped down on Saturday as the party's longest-serving chief for 19 years. She has been keeping unwell in recent years and pushing her son to the fore.

Asked what role she would play after her son's elevation, she told the New Delhiinfo-icon Television channel on Friday: "My role is to retire." However, Randeep Surejewala, a party spokesman, clarified that Sonia Gandhi retired as party president and not from politics.

"Her blessings, wisdom and innate commitment to Congress ideology shall always be our guiding light,'" he tweeted.

The Gandhi family and the Congress party have released little information about Sonia Gandhi's healthinfo-icon problems. She had surgery in the United Statesinfo-icon for an undisclosed reason in 2011, and has returned to the USinfo-icon for regular checkups since then.