(BBC) Nicaragua’s government and opposition groups have agreed a ceasefire after weeks of violence that has left about 170 people dead.

A truth commission will also be established and international investigators allowed into the country.

Friday’s peace talks in Managua were brokered by the Roman Catholic Church.

The protests began on 19 April after President Daniel Ortega’s government imposed cuts to pension and social security programmes.

The cuts were later scrapped but the protests evolved into a rejection of the Ortega government, and thousands of people have since taken to the streets

They also said the truth commission would investigate “all deaths and acts of violence” and identify those responsible.

The UN High Commissioner for Human Rights, the Inter-American Commission on Human Rights (IACHR) and representatives of the European Union would be invited to Nicaragua to help with the inquiry.

The country’s Roman Catholic Church would also play a key role in the process.

Despite the deal, there is still a long way to go before any sense of a stable peace can be achieved, the BBC’s Will Grant reports.

Last month, the IACHR visited Nicaragua and said it had seen grave violations of human rights during the protests.

It said state security forces and armed third parties had used excessive force.

Nicaragua’s foreign ministry has rejected the report as “biased”.

The street protests have become the biggest challenge to Mr Ortega’s authority since he took office in 2007.

He says rallies have been infiltrated by criminals and gang members.

Student activists and union leaders have accused him of violent repression and called for him to step down.

So far, President Ortega has shown little sign of accepting calls for for early elections.

Mr Ortega is a former left-wing Sandinista guerrilla who helped to overthrow the dictatorship of Anastasio Somoza in the 1970s.

However, his critics accuse him and his wife Rosario Murillo, who is his vice-president, of also behaving like dictators.