Chilean protesters won a landmark victory Friday as lawmakers agreed to hold a referendum on the nation’s dictatorship-era constitution, a move that underscored the growing force of street protests that began nearly a month ago as an outcry over a subway fare hike.

The agreement, which calls for a plebiscite in April, was signed early Friday after two intense days and nights of negotiations between opposing parties in the National Congress.

In recent weeks, protests that started with students jumping over subway turnstiles to protest the transit fare increase have morphed into a broader movement joined by left-leaning parties and unionists. President Sebastián Piñera has offered concessions, including a freeze of subway fares, wage and pension increases, tax reform and a new cabinet.

But the protests have not stopped. Demonstrators have demanded a new “social pact” and constitution. Clashes have erupted between protesters and police, who have been accused of torturing, raping and blinding demonstrators. At least 20 people have died and 2,500 have been wounded. Thousands of protesters have been arrested, and some have been charged with setting deadly fires.

Chile, a model of the free market, is South America’s wealthiest nation per capita. But it remains highly unequal, an issue that protesters say is partly the product of a constitution that was drafted during the dictatorship of Gen. Augusto Pinochet and that limited the role of the state.

“We are responsible for many of the injustices, inequities and abuses that Chileans have pointed out to us,” Senate President Jaime Quintana said at a news conference where he presented the two-page agreement. “This is a peaceful and democratic exit to the country’s crisis.”

Protesters celebrated the referendum as a step toward the ­“structural change” they are demanding. Those who have taken to the streets — millions of mostly ­middle-class students, workers and professionals — are angry about shrinking pensions and the high cost of education, health care and public services.

The April referendum, according to the agreement, will ask voters whether they want a new constitution and, if so, whether it should be drafted by ordinary Chileans or a combination of those citizens and lawmakers. The writers of a new constitution would be chosen in October 2020, when regional and municipal elections are scheduled.

A separate vote would approve or reject the new constitution 60 days after the text is published. That vote would coincide with congressional and presidential elections in 2021.

Chileans have long clamored to reform their constitution but never as fiercely as in recent weeks. Protesters want health and education, as well as access to water and decent pensions, to be considered basic human rights rather than nonregulated commodities governed by the markets, and they say the current constitution blocks that possibility.

Students, who were the first to take the streets in mid-October, celebrated but vowed to keep demonstrating.

“The agreement for a new constitution is not enough,” Emilia Schneider, president of the main student federation, said in a tweet. “Transformations are long and difficult processes. It’s a historic opportunity to have a first democratic constitution and we have to take advantage, but we have to stay in the streets to continue pressuring.”

She added, “We can never forget the violations of human rights and their impunity, which are things we need to continue fighting against, urgently.”

Eleven political parties from different points on the political spectrum signed the agreement, which they said sought to “reestablish peace and public order in Chile.”

Analysts called it a milestone but cited challenges in pacifying the country and making the reform process transparent and democratic.

Professor Pablo Viloch said the accord marks Chile’s first “constitutional reform process that is democratic and includes civil participation.” But he cautioned: “There’s no guarantee that violence in the streets will stop. People are hurt and angry.”

Anthony Faiola contributed to this report.