By Charles Haviland
BBC News, Kathmandu
Nepal's midnight peace deal between the government and Maoist rebels aimed at ending the 10-year insurgency is being hailed in fulsome terms.
In the words of one politician, it is "a new era for Nepal". Another sees it as the beginning of the end of the monarchy; while for one Maoist leader it is one of the biggest breakthroughs in the history of Nepal.
With it, the politicians are trying above all to bring an end to the bloody conflict that has brought this desperately poor country to its knees.
The mainstream parties are also attempting to bind the Maoists irrevocably into the political mainstream.
But for King Gyanendra and the institution of the monarchy, the deal offers barely a shred of comfort.
The accord, to be formalised in mid-November, offers gains and losses for all Nepal's political players.
Above all, this is about the Maoists - the communist faction that went underground 10 years ago to wage insurrection, complaining that six years of democracy had brought no good to the country and had failed to uplift its people.
The deal offers them huge gains.
Until May they were regarded as terrorists here; their leaders were wanted men.
But by 1 December they will take their place in a temporary cabinet, sharing ministerial posts equally with each of the other main parties - an attainment of political respectability.
They have made a concession on their weapons - the issue that has constantly hampered progress on an earlier peace agreement which was signed in June but which glossed over many key issues.
The Maoist army will soon be confined in camps and its weapons will be separately locked up. This move will satisfy Prime Minister GP Koirala, who has insisted on rebel disarmament before next year's elections.
Rebel arms were a major point of discussion at the talks
But the Maoists will keep the keys to the stores, albeit under strict United Nations surveillance. This will, it is believed, prevent the senior rebels losing face among the junior ranks, and eliminate any impression that they are surrendering.
The official Nepalese Army is also having to make concessions: it will have the same number of weapons confined.
Having had a bloody role in the conflict, it has moved some way since April. The traditionally royalist institution has had its links with the monarch cut, and its new chief - who has had a highly controversial record in fighting the insurgency - has sworn allegiance to parliament.
The mainstream political parties are having to accept the Maoists, who have never won electoral seats, on equal political terms.
On the other hand, they will occupy key roles in the new transitional government and parliament, with the largest party - the Nepali Congress - keeping, by a small margin, the largest number of parliamentary seats.
Parliamentarians deemed to be "pro-regression" will, however, be excluded from the interim legislature. This move appears to be aimed at staunchly pro-royalist politicians and may attract some criticism as a kind of "victor's justice".
For King Gyanendra and the entire royal establishment, the only comfort is that the monarchy, for the time being, remains in place rather than being suspended.
It now looks as if the first meeting of the assembly due to be elected by June will decide, by a simple majority, whether Nepal will be a kingdom or a republic.
The peace deal may usher in a 'new era' for Nepal
The future of the controversial Shah dynasty, 238 years old, has never looked more precarious.
Its reputation was shattered by the royal massacre five years ago. The present king, Gyanendra, is widely seen to have brought about disaster through his political manoeuvrings; while his wildly unpopular, trigger-happy son, Paras, is unthinkable as a monarch for most Nepalis, even those who maintain respect for the monarchy.
If the dynasty survives, it is impossible to imagine it being given any more than an emasculated, ceremonial role.
Nepal has much unfinished business.
There are unsolved political disappearances committed by both the armed forces and the Maoists; numerous cases of torture and killing in which justice has not even begun to be done. It is an uncomfortable fact that many of the country's political players have blood on their hands.
Currently the onus is particularly on the Maoists to show they can adapt to democratic ways.
Their track record so far is poor. Ironically, within hours of the peace deal being signed, demonstrators were on the streets of Kathmandu, condemning the Maoists for going around houses demanding that Maoist cadres be given food and shelter during a huge Maoist rally planned for Friday.
The Maoists deny exerting such pressure, but the demonstrators insist they are being threatened with violence if they do not comply.
It is the latest example of the Maoists throwing their weight around, acting as if they are already in charge of the country.
The rebels have to adapt to their new role in government
Under the deal, however, their extortions and kidnappings will have to stop. They will even have to dismantle their sophisticated legal system, which has won some admirers.
In one clue to the future, the Maoist spokesman, Krishna Mahara, says the party is changing from being a rebel force into a political force and has promised new policies soon.
The drawing of a rebel movement into peaceful politics always opens a door into the unknown.
Nepalis are now set to learn how these communist rebels, with their red bandanas and seemingly anachronistic beliefs, will adapt to the strange new role of government.