Spain's lower house of parliament voted on Wednesday by 186 for and 144 against to pass the conservative Popular Party's bill, which has been fiercely resisted by rights groups and the left-wing opposition.
The bill now goes for final approval in the Senate, the upper house of parliament, where the ruling Popular Party also has a majority and it is virtually assured to pass before a general election expected in November.
Under the reform, anyone found guilty of inciting crimes against the public order "through any means" can be handed a jail sentence of between three months to a year.
Penalties for public order crimes carried out as part of a group will also be stiffened.
Throwing a rock during a protest could be punished with a jail term of up to six years for example, while the penalty for threatening a police officer at a demonstration will also be hardened.
One of the most contested measures is the planned revision of the criminal code for very serious crimes such as multiple murders or genocide.
Anyone convicted of such crimes would get a life sentence but could be released after serving between 25 and 35 years, depending on the crime and if they can prove in court they have been rehabilitated.
Amnesty International and other rights groups argue that the bill does not clearly specify how someone can prove they have been rehabilitated, meaning they could remain in jail until they die.
Under Spain's existing criminal code the maximum jail term for a serious crime is 40 years.
Amnesty International called the bill's passage in the lower house of parliament "a serious setback for freedom of expression and assembly".
"Due to its ambiguity this criminal code can be applied to people who are peacefully and legitimately exercising their rights," Amnesty spokeswoman María Serrano told reporters outside of parliament after the bill was passed.
Popular Party lawmaker Jose Miguel Castillo Calvin, who heads the party's parliamentary team on justice, told the assembly that the bill "improves on existing regulations".
It will boost the protection of children against online sexual harassment, better protect women against domestic violence, and prevent the statute of limitations from applying to terrorist crimes, he said.
Passage of the bill comes just a month after the lower house of parliament approved a new citizen security law introducing hefty fines for unauthorized protests, which has been dubbed the "Gag Law" by its critics.