KATHMANDU (Reuters) - Nepal President Bidhya Devi Bhandari on Thursday appointed moderate communist K.P. Sharma Oli, who led an alliance with former Maoist rebels to a sweeping victory in recent elections, as prime minister.

FILE PHOTO: Nepal's Prime Minister Khadga Prasad Sharma Oli, also known as K.P. Oli, observes a minute of silence for earthquake victims during an event organised to mark the 18th National Earthquake Safety Day and the official launch of earthquake reconstruction efforts in Bungamati village, Nepal January 16, 2016. REUTERS/Navesh Chitrakar/File photo

A presidential spokesman said Oli, who spent 14 years in jail for opposing the now-abolished monarchy in the 1970s and 1980s, was named prime minister hours after Sher Bahadur Deuba, whose party suffered a landslide defeat in the polls, resigned.

Oli was also prime minister from 2015 to 2016, soon after the nation’s current constitution was formalized.

Oli’s leftwing alliance is considered to be closer to China while outging leader Deuba is widely seen as being closer to India.

The two Asian giants have poured aid and investment to woo Nepal, home to Mount Everest, as a geo-political ally.

“Oli is going to be pragmatic as prime minister to balance India and China,” said Kunda Dixit, editor of the weekly Nepali Times.

Nepal held parliamentary elections in November and December but the formation of the new government had been delayed because the Election Commission declined to declare the final results until the election of the upper house of parliament, which was held last week.

“He has already received the appointment letter from the president,” Bhandari’s spokesman, Kul Prasad Chudal, told Reuters.

Oli is to take the oath of office later on Thursday, Chudal said.Nepal has been embroiled in political instability since a decade-long Maoist conflict ended in 2006 and the monarchy was abolished two years later. Oli is the 26th prime minister since protests led to the establishment of a parliamentary democracy in 1990.

Oli has said he will promote peace, stability and development in one of the world’s poorest countries where revolving-door coalitions have sapped business confidence, curbed growth, spurred corruption and slowed reconstruction after a 2015 earthquake that killed 9,000 people.

The new government will be faced with an economy plagued by dwindling exports, manufacturing and remittances.

Party officials said Maoist chief Prachanda will take over from Oli as prime minister before his five year term expired under a power sharing deal.