The deal was signed by Girija Prasad Koirala, the prime minister, and Prachanda, the leader of the Maoist rebels, at a Kathmandu convention hall filled with cheering officials, dignitaries and foreign diplomats.
Prachanda said he was optimistic that peace could be achieved but that it was important to incorporate the rebels into the state army.
The signing was applauded internationally, with the US embassy in Nepal saying it hoped the accord would put Nepal "on the path of lasting peace and democracy", and pledging its full support.
Under the deal the rebels will join the parliament by November 26 and get 73 of its 330 seats. Both sides agree to uphold all international human rights and civil liberties.
The king will be stripped of political rights, and his property will be nationalised under public trusts. The deal also includes strong punitive policy against corruption; property earned illegally can be confiscated.
More than 13,000 people have been killed in the conflict that has centered on the Maoists' opposition to Nepal's 200-year-old monarchy.
Nepalese boys celebrate the
signing of the peace agreement
King Gyanendra discharged Nepal's elected politicians and took control of the country last year.
In April rebels teamed up with Nepal's largest political parties to back mass protests against the king, which helped bring the government back to power — though not before 21 people were killed and thousands were injured.
A high level panel this week concluded that the king had used excessive force against the pro-democracy demonstrators.
One of the Maoists' top demands has been the holding of elections to decide whether Nepal will remain a monarchy. The peace deal addresses those concerns; the interim government will organise elections next year to determine the fate of the monarchy.
A ceasefire between the two sides has been observed for six months, but human rights groups have accuse the rebels of continuing to recruit in the countryside, a charge the rebels deny.
A joint-UN team on Monday headed to Chulachuli, Ilam, to investigate the allegations.