SPAIN'S socialist government has struck a deal with the country's trade unions to raise the age of retirement.
All parties have agreed that the compulsory retirement age will increase from 65 to 67, one of the highest in Europe.
A final, marathon discussion ran into the early hours of yesterday morning.
The deal is a crucial step to convince investors the government is committed to structural reform to revive the economy and avoid a bail-out.
Aware it was under international scrutiny, the government had threatened to impose the changes by decree if necessary. Spain's trade unions had warned of another general strike.
Since early January, the two sides have been holding long weekends and late nights of talks.
With a low birth rate and increasing life expectancy, government figures suggest 32% of Spain's population will be aged 64 or over by 2050. The number of pensioners is expected to rise from eight million to 12 million over the next 3 decades.
Under the current system, pension payments account for around 9% of public spending. By 2040, that figure could rise to 14%, according to the Economy Ministry.
Unemployment is also straining the system. Figures released by the national statistics institute yesterday revealed that the number of people out of work had surged to a 13-year record high of 20.33% in 2010.
Last year, for the first time, the social security system was not in surplus.
A social security crisis is looming in Spain, as elsewhere. So despite disagreement over the details, there is broad consensus about the need for change. If the reform is finally approved, the government will have chalked-up a success and the unions will not have taken a step back, was the reflection of an El Pais newspaper editorial, which calculates that the reform maintains the solvency of the system. The general acceptance of the reasons for the change, and the spirit of negotiation, allow us to be optimistic, the paper concludes.
Not everyone accepts the deal, though.
The first real protests erupted on Thursday as a demonstration against the reforms by far left-wing groups turned violent.
Riot police clashed with dozens of young protestors who overturned and burned rubbish containers, threw firecrackers and smashed the glass facades of several banks. Eight police officers were injured.
There have been demonstrations by some unions against the pension reforms Last week, trades unionists staged sit-ins at social security offices.
By reaching agreement with Spain's most powerful unions, though, the government appears to have deflected the danger of major social unrest.
It is particularly keen to avoid another general strike, with local elections looming in May.
But it has been forced to row back somewhat from its initial proposal for reform.
It had insisted that to retire on a full pension, a person would have to work and pay into the system for 41 years, up from 35.
The unions pushed for 38. The final agreement is 38.5.
The age of retirement will also increase progressively, from 2013, so that those close to pension age now will not be affected.
Trade union leaders stress that they reserve the right to make further alterations to the reforms before their final approval by parliament.
But it has been agreed that pensions will now be calculated on the basis of the last 25 years of a worker's earnings, instead of the current figure of 15, a system that one economist had described as not just generous, but silly.
The reform appears daunting to some of Spain's younger generation.
Forty per cent of young people are unemployed; many are approaching the age of 30 without work, never having paid into the social security system.