Media playback is unsupported on your device Media caption Shwe Mann was considered a possible future presidential candidate but now appears to be under house arrest

Myanmar's parliamentary speaker Shwe Mann has been ousted from his role as chairman of the ruling USDP party, amid a power struggle.

Security forces surrounded the USDP offices on Wednesday, preventing officials from leaving.

Myanmar is holding elections in three months, its first since democratic reforms began in 2011.

Shwe Mann had been rumoured to be discussing an alliance with opposition leader Aung San Suu Kyi.

Ms Suu Kyi's National League for Democracy (NLD) is expected to do well in the 8 November elections, while many believe the ruling Union Solidarity and Development Party (USDP) will perform poorly.

However, Ms Suu Kyi is barred by the constitution from contesting the presidency, so negotiations between the NLD and USDP could help determine who ends up leading Myanmar, also known as Burma.

Read more: Myanmar's 2015 general elections explained

Image copyright Getty Images Image caption Police officers remained outside the party headquarters on Thursday

Analysis by Moe Myint, BBC Burmese service

Aung San Suu Kyi and Shwe Mann have often expressed that they have a mutual understanding for future co-operation.

One likely area is thought to be amendment of the constitution, which prevents Ms Suu Kyi from running for the presidency.

But for conservative forces in the ruling USDP party and the military, constitutional change is seen as a threat - because the constitution gives the military an automatic 25% of seats in parliament, and safeguards the traditional alliance between the USDP and the armed forces.

This latest move means an inner circle of the president's has come out on top. It could also worsen the relationships between the ruling elites and the opposition.

Until last night Shwe Mann, one of the most capable generals in the old military regime, had been seen as a likely successor to President Thein Sein, the BBC's South East Asia correspondent Jonathan Head reports.

Thein Sein and Shwe Mann are said to have had a tense relationship, with both men suggesting they would accept the role of president.

The two also disagreed over potential election candidates, reports said.

Sources say Shwe Mann has now been replaced by a conservative known to be close to Thein Sein and formerly military ruler Than Shwe.

Security forces could be seen outside his home on Thursday.

"Shwe Mann isn't the chairman of the party anymore," a USDP member told Reuters. "He's in good health and at home now."

Image copyright AFP Image caption Shwe Mann was one of the most capable generals in the old military regime

A nominally civilian government was introduced in Myanmar in 2011, ending nearly 50 years of military rule.

President Thein Sein introduced reforms including freeing hundreds of prisoners and relaxing media censorship.

However, the military still maintains massive influence in Myanmar's politics, with a quarter of seats in both parliamentary chambers reserved for the military.