Turkey's parliament has backed a motion that could allow its military to enter Iraq and Syria to join the campaign against Islamic State (IS) militants.
The resolution - passed with a three-quarters majority - will also permit foreign troops to use Turkish territory for the operation.
Turkey has been under pressure to play a more active role in the US-led fight.
The government dropped its reluctance to combat IS militants directly after the release of 46 hostages last month.
The Turkish citizens had been held by IS in northern Iraq.
However, Turkey still remains wary of retaliation by IS and also fears helping Kurds, who are fighting the militants. Turkey has fought a long civil war with its Kurdish minority.
Protesters demonstrated outside parliament as the debate began but the motion was passed with 298 MPs in favour and 98 against.
It provides a legal framework for the Turkish military to launch incursions into Syria and Iraq against militants who threaten Turkey. It also allows for foreign troops to be stationed in Turkey as part of the same campaign.
The approval of the MPs could enable the US to use its large airbase at Incirlik in southern Turkey for air strikes against IS.
Asked what action Turkey might take now, Defence Minister Ismet Yilmaz told Associated Press news agency: "Don't expect any immediate steps."
Turkey has long been accused of permitting the flow of jihadists and resources into Syria as well as allowing IS to traffic oil from oilfields it has captured. The government in Ankara denies the allegations.
Turkey has a porous and vulnerable border with Syria, more than 900km (560 miles) long.
Analysis: BBC's Mark Lowen in Istanbul
With a strong majority in parliament, the result of the vote was never in doubt. But whether this motion translates into Turkish troops being sent into battle is another matter.
Turkey shares a long, vulnerable border with Iraq and Syria and fears retaliation, not least against Turkish troops protecting an Ottoman tomb in Syria, which IS militants have approached. It is reluctant to help the Kurds - with whom Turkey fought a long civil war - in their fight against IS.
And it wants the coalition to broaden its aims, so that military intervention targets the Assad regime and a buffer zone is set up in Syria to help cope with the refugee influx, both of which seem some way off. Some analysts believe that by using a blanket term in the motion - "terrorist organisations" - rather than mentioning Islamic State by name, Ankara's real target is the Kurdish PKK, still on the terrorist list.
But Kurds on the ground say that if Turkey wants IS pushed back from its borders, it must help Kurdish fighters in Syria, rather than seeing them as the enemy.
Speaking in parliament earlier on Wednesday, President Recep Tayyip Erdogan urged the West to find a long-term solution to the crises in Syria and Iraq, pointing out that dropping "tonnes of bombs" on IS militants would only provide a temporary respite.
While he said "an effective struggle" against IS would be a priority for Turkey, "the immediate removal of the administration in Damascus" would also continue to be key.
He has repeatedly called for a buffer zone on the Turkish border inside Syria - enforced by a no-fly zone - to ensure security.
- "Turkey should say that it is not a part of this war; that its contribution will be to protect the innocent" - Markar Esayan, in pro-government Yeni Safak
- "It is not possible to be optimistic about any of the scenarios related to this motion" - Okay Gonensin in centrist Vatan
- "[This motion] will please neither the Syrian administration, nor the Kurds and Arabs - Ali Bulac in moderate Islamist paper Zaman
IS militants have advanced to within a few kilometres of the Kurdish town of Kobane, on the Syrian border with Turkey.
Imprisoned Kurdish militant leader Abdullah Ocalan was reported by Reuters on Thursday to have warned that peace talks between his group and the Turkish state would end if IS militants were allowed to carry out "a massacre" in Kobane.
The Islamic State advance close to the border has prompted thousands of Kurdish refugees fleeing the fighting in Syria to enter Turkey, which is already hosting more than a million Syrian refugees.
The IS campaign has also raised fears for the safety of Turkish special forces troops in Syria guarding the mausoleum of Suleyman Shah, the grandfather of Osman I, who founded the Ottoman Empire. The tomb is in a small enclave some 30km (18 miles) south of the Turkish border.
Mr Erdogan denied reports on Wednesday that the tomb had been surrounded by militants.
- Formed out of al-Qaeda in Iraq (AQI) in 2013, IS first captured Raqqa in eastern Syria
- It captured parts of Iraq in June, including Mosul, and declared a "caliphate" in areas it controls in Syria and Iraq
- Pursuing an extreme form of Sunni Islam, IS has persecuted non-Muslims such as Yazidis and Christians, as well as Shia Muslims, whom it regards as heretics
- Known for its brutal tactics, including beheadings of soldiers, Western journalists and aid workers
- The CIA says the group could have as many as 31,000 fighters in Iraq and Syria