Image copyright AFP/Getty Imagea Image caption Sultan Abdullah of Pahang state has been elected the new king

Malaysia has elected Sultan Abdullah of Pahang as its new king after the shock abdication of the previous monarch.

Sultan Muhammad V of Kelantan abdicated in January after just two years on the throne, a first in Malaysian history.

Malaysia has an unusual constitutional monarchy, where the top job rotates between nine hereditary state rulers every five years.

The king, known as the Yang di-Pertuan Agong, is largely ceremonial and does not participate in daily governance.

The Sultan of Pahang - a large state in Peninsular Malaysia - is expected to be sworn into his new role on 31 January.

He was only sworn in as Sultan of Pahang earlier this month.

Sultan Muhammad V, who was 47 when he became king, was known for his enthusiasm for extreme sports like off-road driving, shooting and endurance challenges.

In November last year, he said he was taking medical leave. Later that month, photos began circulating on social media that appeared to show him being married to a former Miss Moscow in the Russian capital.

However no reason has been given for his abdication.

What is Malaysia's monarchy system?

The role of the Yang di-Pertuan Agong dates back to 1957 when the Federation of Malaya declared independence from the British Empire.

The 13 states that make up Malaysia each have a seat on the Conference of Rulers, a council made up of the nine traditional Malay rulers and governors from the four remaining states without a royal family.

Each five years, the nine traditional leaders vote for which of them should next take the throne.

How is the new king selected?

The nine are given a ballot paper with only one name, typically the name of the sultan from the state next in line. They then anonymously indicate whether or not they think the sultan is suitable for the role.

Image copyright AFP Image caption Malaysia's king Sultan Muhammad V unexpectedly abdicated the throne in January

A ruler has to secure a five-vote majority to be the next king. If he does not secure enough votes or declines the position, the election process is repeated with the name of the sultan from the state next in line.

To ensure anonymity, the nine rulers are given unnumbered ballot papers with identical pens and ink.

What power does the king have?

The position is largely ceremonial, with power in the hands of parliament and the prime minister.

But he is in charge of major appointments like that of the role of prime minister, is the head of Islam in Malaysia and the commander-in-chief of the armed forces.

He also has the power to grant pardons which is what the previous king did for former opposition leader Anwar Ibrahim after his coalition's shock victory during last year's general elections.

Mr Anwar was pardoned from a conviction for sodomy which was widely seen as politically motivated.

The role of Yang di-Pertuan Agong is accorded considerable prestige, particularly among the country's Malay Muslim majority, for whom the king is seen as upholding Malay and Islamic tradition. Criticism deemed to incite contempt of the king can attract a jail term.

Most recently after Muhammad V's resignation, online vigilantes were seen policing social media and releasing personal information of anyone found criticising the monarchy.

According to local news site Malay Mail, a Facebook page was set up listing eight individuals of which at least three were investigated under Malaysia's Sedition Act while another four were either fired, suspended or resigned from their jobs.