Media playback is unsupported on your device Media caption The signing ceremony is the result of two years of negotiations

Myanmar has signed a ceasefire deal with eight armed rebel groups, in the hope of ending decades of conflict.

President Thein Sein said the deal had opened up the "road to future peace" in Myanmar, also known as Burma.

But the most active of rebel groups have not signed the agreement, which comes after two years of negotiations.

Myanmar has been engaged in armed conflict with various ethnic and other groups seeking greater autonomy since independence from the British in 1948.

The violence has left tens of thousands dead over the years, displaced hundreds of thousands more and has been used by the military to justify its long hold on political power.

Resolving the conflicts is seen as central to Myanmar's attempts to reform after decades of military rule.

'Peaceful future'

The government hopes Thursday's deal - which comes weeks ahead of general elections - will be the first step on a path to a lasting political settlement.

Image copyright Reuters Image caption Representatives of the UN, the EU and China were among the international witnesses to the deal

Speaking at the lavish signing ceremony in the capital, Nay Pyi Taw, Thein Sein said it was a "historic day for Myanmar".

"We have been able to launch a new road to a peaceful future of our country."

The chairman of one of the armed groups, the Karen National Union (KNU), called it "a new page in history and a product of brave and energetic negotiations".

Analysis: Jonah Fisher, BBC News, Nay Pyi Taw

Image copyright AFP Image caption The All Burma Students Democratic Front (shown) has signed but their ally, the Kachin Independence Army, has not

The agreement is neither truly nationwide nor strictly speaking a ceasefire.

In order to take part in this collective agreement the armed groups had to have previously signed a bilateral ceasefire with the government. So it is not actually halting any conflicts.

This at times tortuous process has been about trying to get everyone to the start line before the next phase, political dialogue, gets under way.

With only about half the groups having made it to the start line, the way forward from here will be ever more complex.

Read more: Ceasefire marks milestone for Myanmar

But seven of the armed groups which have been involved in the talks did not sign the final deal.

Among them is the largest, the United Wa State Army (UWSA), which has some 25,000 members operating on the border with China, and has largely remained on the sidelines of the talks.

Also not signing was the Kachin Independence Organisation (KIO), whose Independence Army (KIA) controls large areas of north-eastern Kachin state and has regularly clashed with the Burmese army since a ceasefire collapsed in 2011.

Image copyright AP Image caption The Karen National Union has fought the state since the early days of Burma's independence

Thein Sein said the government would "continue with our efforts to bring the remaining organisations into the process".

"The door is open for them," he said.

Political discussions are now due to begin within months on the structure of a new, and probably more federal, system of government, says our correspondent.

But there are still concerns that peace with the groups signing Thursday's agreement could be short lived, if the Burmese army ignores the ceasefire, as it has with others.

Earlier this week, all of the groups signing were removed from the government's list of "unlawful associations", a step towards bringing them into mainstream politics.

Opposition leader Aung San Suu Kyi, who has previously urged rebel groups to focus more on a lasting deal than a quick one, was not at the signing ceremony.

Representatives from the United Nations, the European Union, India and China and others witnessed the signing.