PM Koirala and rebel leader Prachanda celebrate the signing
Under the deal, the rebels will join a transitional government and their weapons will be under UN monitoring.
Both sides have been accused of human rights abuses in fighting that has left more than 13,000 people dead.
Prime Minister Girija Prasad Koirala and Maoist rebel leader Prachanda signed the deal in Kathmandu.
End to conflict
"This ends the more than one decade of civil war in the country," Prachanda said after the deal was signed.
This moment marks the end of the 238-year-old feudal system
Maoist leader Prachanda
Viewpoints: Historic peace Should the king be punished?
The country's multi-party government and the Maoist rebels have been observing a ceasefire for more than six months since they co-ordinated mass protests that forced King Gyanendra to restore parliament and end direct rule.
The BBC's Charles Haviland in Kathmandu says that the agreement brings an end to years of bloody conflict.
The Maoists are now due to move into parliament and government, abandoning their guerrilla status.
Our correspondent says that the agreement has been expected for several days, but is nonetheless historic.
"The war is over," declared the chief government negotiator, Krishna Sitaula, as he read out the agreement reached after tortuous negotiations.
He said the ceasefire declared by both sides six months ago had become permanent.
Arms belonging to the rebels will be monitored by the UN
Anyone committing violent acts from now on would be punished, Mr Sitaula added.
In a celebratory atmosphere, the peace agreement was made public at a large gathering of politicians, diplomats and civil society leaders in Kathmandu.
"This moment marks the end of the 238-year-old feudal system," 52-year-old Prachanda declared.
"Our party will work with new responsibility and new vigour to make a new Nepal."
Mr Koirala was equally ecstatic. "The agreement has ended the politics of killings, violence and terror and started the politics of cooperation," he said.
"I would like to thank Prachanda as well for finding a peaceful solution. Nepal has entered into a new era and it has opened the door for peace.
"Now we need to meet together in cooperation and understanding to make sure this agreement is fully implemented," the 85-year-old PM said.
The UN has welcomed the deal, describing it as "another key step forward in the peace process".
Flag of Nepal

Nepal's 10-year civil war has come to a peaceful conclusion with the signing of a historic accord between Prime Minister Girija Prasad Koirala and Prachanda, leader of the Maoist rebel faction that had been fighting for political change. The deal was signed in Kathmandu on Tuesday.

The deal would allow the Maoists into the Nepalese government, and place both Maoist and government weapons under UN scrutiny. The Maoists had been observing a ceasefire since its declaration more than six months previously.

Prachanda said that the peace agreement would end the 238-year old feudal system. He added that his party would work with new responsibility and make new strong Nepal.

Meanwhile, Koirala said that the deal ended the politics of terron and violence and started the politics of co-operation. He thanked Prachanda to find out a peaceful solution in the country.

The government and the Maoist rebels were accused of human rights abuses in fighting that killed more than 13,000 people.

Nepalese king Gyanendra Singh has welcomed Tuesday's peace deal between the government and the Maoist rebels.