Media playback is unsupported on your device Media caption When Myanmar's next president went to jail

Myanmar's parliament has elected Htin Kyaw as the country's next president, the first civilian leader after more than 50 years of military rule.

Htin Kyaw is a close ally of Aung San Suu Kyi, whose National League for Democracy (NLD) party swept to victory in historic elections in November.

He said his appointment was "Aung San Suu Kyi's victory".

Ms Suu Kyi is barred from the post by the constitution, but has said she will lead the country anyway.

How Suu Kyi could be more powerful outside the presidency

Htin Kyaw won with 360 of the 652 votes cast in the two houses of parliament, with MPs erupting into applause when the result was announced.

"Victory! This is sister Aung San Suu Kyi's victory. Thank you," Htin Kyaw said after winning.

At the scene: Jonah Fisher, BBC News, Nay Pyi Taw

Image copyright AP Image caption As well as being a writer himself, Htin Kyaw is the son of a national poet and the son-in-law of a founder of the pro-democracy movement

The end result when it finally came was entirely as expected, with a landslide victory for Ms Suu Kyi's man, Htin Kyaw.

Given the miseries that this country has suffered this was another incredible momentous occasion.

But if she was enjoying it , or reflecting on the sacrifices that were made to get here, Ms Suu Kyi gave no indication. Just as she has done since the election in November, the former pro-democracy campaigner avoided the media and made no public comment.

No doubt acting on her instructions (probably a taste of what's to come) Htin Kyaw remained elusive.

The only time I saw Myanmar's next president was at the end of a cordoned-off corridor, waiting for the arrival of Ms Suu Kyi.

Image copyright AP Image caption Burmese across the country gathered in teashops and homes to watch the voting broadcast live from parliament

In second place was Myint Swe, who was nominated by the military and received 213 votes. A close ally of former junta leader Than Shwe, he is seen as a hardliner.

He was followed by Htin Kyaw's running mate and ethnic Chin candidate Henry Van Thio, who got 79 votes.

They will serve as first vice-president and second vice-president respectively.

The president is chosen from candidates put forward by each of the two houses of parliament, in addition to a third nominee from the military.

Image copyright Reuters

Who is Htin Kyaw?

Htin Kyaw, 70, is Ms Suu Kyi's close aide.

He is said to be a quietly spoken man who attended university in the UK. He has a reputation for honesty and loyalty, and has kept a low profile.

His father, the writer and poet Min Thu Wun, won a seat for the party at the 1990 election.

His wife, Su Su Lwin, is the daughter of an NLD founder, as well as being a sitting MP, and a prominent party member.

He has played a senior role at the Daw Khin Kyi Foundation, the charity founded in honour of Suu Kyi's late mother, and has been frequently seen at the NLD leader's side, serving as her driver from time to time.

The NLD has a huge majority in both houses of parliament, despite the military occupying 25% of seats, so the candidate it backed was all but guaranteed to win.

But correspondents warn of increasing confrontation in parliament in the future as MPs push against an army determined to hold onto the powers it has under the constitution.

It still controls key security ministries and also has the power to veto any changes to the constitution as that would require more than 75% of parliamentary votes.

Correspondents say that Htin Kyaw's election is widely supported among the Burmese people, as he has a solid reputation and is known to be trusted by Ms Suu Kyi.

Despite her popularity and prominence in Myanmar - also known as Burma - Ms Suu Kyi could not take the presidency herself.

A clause in the constitution, widely seen as being tailored against her, says anyone whose children have another nationality cannot become president. Her children hold British passports.

Despite weeks of negotiation prior to the vote, the NLD were unable to persuade the military to remove or suspend the clause to allow Ms Suu Kyi to take office.

However, Ms Suu Kyi has previously said that she would be "above the president" anyway, ruling through a proxy.