Turkey's parliament has given legal authority to the military to launch cross-border raids into Syria in response to Wednesday's deadly mortar strikes that killed five civilians and edged the two former allies closer to a big conflict.

The vote to allow the military to cross into Syria at any point over the next year was passed by 320 votes to 129.

Turkish prime minister Recep Tayyip Erdogan said on Thursday that Turkey did not want war with Syria following the shelling on the town of Akçakale, but was determined to protect its borders and its people. "We want peace and security and nothing else. We could never want to start a war," Erdogan said. "Turkey is a country which is capable of protecting its people and borders. No one should attempt to test our determination on the issue."

Erdogan suggested the Syrian shelling was not accidental, saying shells had fallen on Turkish territory on seven previous occasions since the civil war began.

The UN security council also issued strong condemnation of the Akçakale attack. A security council statement on Thursday night said: "This incident highlighted the grave impact the crisis in Syria has on the security of its neighbours and on regional peace and stability."

The council demanded an immediate end to such violations of international law and called on the Syrian government "to fully respect the sovereignty and territorial integrity of its neighbours".

The statement managed to bridge differences between the US and its western allies which were demanding a strong text and Syria's most important ally, Russia, which tried to soften the text.

Ankara said it had received an apology from the Syrian regime on Thursday, relayed by the UN, and an assurance that such an incident would not occur again.

The moves by the Turkish parliament followed a day of high tension on the restive frontier and at least 12 hours of artillery fire from southern Turkey at targets deep inside north Syria.

Observers outside the country who had spoken to activists in Tel Abyad, about nine miles from the border, claimed an unknown number of Syrian soldiers had been killed by the Turkish fire and others had withdrawn from their bases.

As the shellfire ceased shortly after sunrise on Thursday, officials in Ankara announced that Erdogan would turn to parliament for the same sort of legal backing that underpinned the country's operations against Kurdish groups in north Iraq.

Erdogan's motion said the shelling had been "on the threshold of an armed attack" and was a "serious threat to Turkish national security".

The statement said: "As part of the military operations being conducted by the Syrian Arab republic armed forces, starting from [20 September] aggressive actions have been directed against our country's territories too. These actions have continued despite our repeated warnings and diplomatic initiatives.

"Therefore, the need has developed to act rapidly and to take necessary precautions against additional risks and threats that may be directed against our country."

Besir Atalay, the deputy prime minister, later said: "The bill is not for war. It has deterrent qualities."

On Thursday Turkey moved troops and armour to the area near the town of Akçakale, which was hit late on Wednesday afternoon by at least two shells fired from Syria. Officials said radar tracks had shown the firing point was about six miles inside Syria, near a military base used by regime troops.

The Syrian strike was roundly condemned by Nato, of which Turkey is a member state, as well as the UN and US.

Russia, a staunch ally of Damascus and backer of Bashar al-Assad, Syria's president, in the uprising, said it had asked its ally to explain what had happened and to apologise for any "mistake".

Atalay later claimed to have received the indirect Syrian apology. There was no immediate comment from Damascus.

Turkey and Syria had edged towards conflict in the summer when a Turkish jet was downed by a missile fired from Tartous, in Syria. On that occasion, Turkey invoked the Nato treaty that can require the powerful security body to defend a member state under attack. Ankara did not retaliate at the time but said it would do so against future provocations.

Syria has accused Turkey of arming and sheltering the Free Syria army, its main adversary in the now blazing civil war. Syrian officials brand the rebel forces terrorists and say they are backed by foreign powers.

Anders Fogh Rasmussen, Nato's chief, reiterated to the Guardian on Monday that Nato would not support a Libya-style military intervention in Syria. "Syria is a very, very, complex society. Foreign military interventions could have broader impacts."

An urgent meeting of Nato ambassadors hours after the Syrian strike produced a strongly worded statement condemning Damascus, but offered no hint that its anti-intervention stance had changed.

"The alliance continues to stand by Turkey and demands the immediate cessation of such aggressive acts against an ally, and urges the Syrian regime to put an end to flagrant violations of international law," it said.

Meanwhile, close to 100 people were reported to have died across Syria on Thursday as fighting continued to rage in most parts of the country.

The popular uprising, inspired by the Arab spring, which by earlier this year had morphed into an intensive armed insurrection, has now claimed in excess of 30,000 lives and shows no signs of abating.

Aleppo and Damascus are battle zones, as are most secondary cities and towns. The deteriorating situation in Syria poses an ever increasing risk to neighbouring states, including Turkey, which is already battling an insurgency led by restive Kurdish groups in Iraq and Syria.