The rare agreement on a Syria statement condemned the attack "in the strongest terms" and came after Russia rejected an initial text on Wednesday's incident and proposed a diluted version calling on both Turkey and Syria to exercise restraint.
Western council members objected to Moscow's text but revised the original draft to accommodate some Russian concerns.
Consensus within the council on anything related to Syria is unusual and it has been deadlocked on the issue of the country's 18-month-long conflict for more than a year, with Russia and China rejecting calls to sanction the Damascus government.
The text of the final statement from the 15-member Security Council "called on the Syrian Government to fully respect the sovereignty and territorial integrity of its neighbors" and "demanded that such violations of international law stop immediately and are not repeated."
"The members of the Security Council underscored that this incident highlighted the grave impact the crisis in Syria has on the security of its neighbors and on regional peace and stability," it said.
The mortar attack happened on Wednesday and Turkey responded by striking targets in Syria later the same day and on Thursday.
Instead of explicitly calling on both Turkey and Syria to exercise restraint, the final sentence of the declaration read: "The members of the Security Council called for restraint."
Russia insisted on removing a sentence in the original draft calling the Syrian attack "a serious threat to international peace and security." The compromise text referred instead to concerns as to the impact of the crisis in Syria on "the security of its neighbors and on regional peace and stability."
Russia and China have vetoed three resolutions condemning Syrian President Bashar Assad's government and diplomats say it is unlikely the Security Council will take further action on Syria for the time being.'Atrocious terrorist bombings'
About 30,000 people have been killed across Syria in an escalating conflict between Assad's forces and rebels seeking to oust him, opposition activists say. The war has seen growing sectarian overtones which threaten to draw in regional Sunni Muslim and Shiite powers.
Earlier on Thursday, UN spokesman Martin Nesirky said UN Secretary-General Ban Ki-moon was "alarmed by escalating tensions along the Syrian-Turkish border" and worried that the risk of a wider regional conflict was growing.
Syria's UN Ambassador Bashar Jaafari said his government had urged the Security Council to include in any statement on the border attacks a reaction to "suicide terrorist attacks that struck the city of Aleppo" on Wednesday.
Aleppo was not mentioned in the council statement but Russia's delegation said it would circulate a separate draft text condemning the Aleppo attack to the council later on Thursday, which it hopes will be adopted on Friday.
Ban described the bombings in the northern Syrian city, which killed 48 people, as "atrocious terrorist bombings," while Jaafari accused some Security Council members of blocking for the third time a condemnation of "terrorist" attacks in Syria.
"The Syrian government is not seeking any escalation (of the conflict) with any of its neighbors, including Turkey," Jaafari told reporters. "We reiterate our call to the Turkish government to help us in controlling the border, preventing armed groups from infiltrating through these borders."
Syria has accused Turkey, the United States, France, Qatar and Saudi Arabia of supporting "terrorism" by funneling arms, money and foreign fighters to rebels. Qatar, Saudi Arabia and Turkey have denied aiding the rebels. The United States and France say they are providing "non-lethal" support, not weapons.
The council statement came in response to a request from Turkey, which asked council members to take the "necessary action" to stop Syrian aggression and ensure that the government there respects Turkish territorial integrity.
Syria wrote to the council offering condolences for the deaths of Turkish civilians and calling for restraint and rationality.
UNITED NATIONS (Reuters) -- The UN Security Council on Thursday condemned a Syrian mortar attack on a Turkish border town that killed five people and demanded that "such violations of international law stop immediately and are not repeated."