Spanish lawmakers on Tuesday urged their government to recognise Palestine as a state, albeit only when the Palestinians and Israel negotiate a solution to their long-running conflict.
The symbolic motion, which echoes similar votes last month in Britain and Ireland, received the backing of all the political groups of the lower house. 319 lawmakers voted in favor of the motion, two voted against and one abstained.
The wording in the motion was changed to emphasize that the move for a Palestinian state should be "the consquence of a process negotiated betweent the parties."
The debate in Madrid comes on a day when two Palestinians armed with a meat cleaver and a gun burst into a Jerusalem synagogue and killed four Jews at prayer before being shot dead.
The non-binding motion, brought forward by the opposition Socialists, had initially "urged" the government to recognize a Palestinian state, angering the Israeli government.
But the ruling People's Party (PP), which holds an absolute majority in the lower house, proposed an amendment hours before the vote weakening the text.
"The Spanish parliament urges the government to encourage the recognition of Palestine as a state... This recognition should be the consequence of a process negotiated between the parties that guarantees peace and security for both," the wording proposed by the PP said.
The amended resolution appeared less ambitious than Foreign Minister Jose Manuel Garcia-Margallo had hoped.
"We have the feeling that time is running out," he told reporters in Brussels on Monday. "Either we do something fairly quickly or the two-state solution will be physically impossible."
Talks were continuing in parliament to try to secure a deal among all political groups on the motion ahead of the vote that had been due on Tuesday evening.
The Spanish initiative, promoted by Socialist former Foreign Minister Trinidad Jimenez, came after lawmakers in Britain and Ireland called for their governments to recognize a Palestinian state.
France is also eyeing such a non-binding resolution later this month after Sweden's center-left government took the lead by officially recognizing the state of Palestine within days of taking office last month.
The moves reflect mounting frustration in the European Union at Israel's expanding settlement program on land the Palestinians want for a state following the collapse of US-sponsored peace talks.
The EU's new foreign policy chief, Federica Mogherini, said the bloc's 28 foreign ministers discussed at a meeting in Brussels on Monday how they could start "a positive process with the Israelis and Palestinians to relaunch a peace process".
Asked about the PP amendment, Palestinian ambassador Musa Amer Odeh, who planned to attend the debate, said: "The most important thing is that the parliament is asking the government to recognize the state of Palestine."
The Israeli government had earlier dismissed the gesture, saying it came at the worst possible moment on the day of the deadliest incident in Jerusalem in six years.
"Nothing can be gained from unilateral moves such as the one being made by the Spanish parliament today and it distances us from negotiations with the Palestinians," said Israeli foreign ministry spokesman Emmanuel Nahshon.
"We call on Spain not to make unilateral moves, particularly on a shocking day like today," said Nahson.
Spanish Prime Minister Mariano Rajoy condemned the attack.
"The Spanish government and all the Spanish people are deeply moved and united with Israel and its citizens in this moment of intense pain and indignation," he said in a telegram sent to Israeli Prime Minister Benjamin Netanyahu.