BEIRUT — Rebels fighting in Syria’s civil war crossed into Lebanon and raided a border town Saturday, killing and capturing security force members in the most serious incursion into the tiny country during its neighbour’s 3-year-old conflict.

The rebels, who included foreign fighters, demanded to trade soldiers and police officers it captured in Arsal for some of the “most dangerous detainees,” the Lebanese army said in a statement. Masked gunmen roamed the streets as Lebanese helicopter gunships flew over the town, about 90 kilometres (55 miles) from the capital, Beirut.

A Lebanese army general told The Associated Press that the gunmen attacked army positions near Arsal and troops returned fire. Another official said the gunmen also took control of the main police station in the town.

Lebanon’s state-run National News Agency reported that Arsal residents later freed police officers at the station, though rebels captured some weapons and released several detainees. It said gunmen killed two residents near the police station.

A picture posted online allegedly showed gunmen in Arsal driving away with about a dozen men, two of them in police uniforms. The photograph corresponded to other AP reporting about the attack.

Gunmen killed two soldiers and wounded several others, the National News Agency reported.

A Lebanese army’s tank drives to the entrance of the town of Arsal in the Bekaa valley by the Syrian border on August 2, 2014 as they arrive to secure the area where gunmen killed four people, including two soldiers, after clashes erupted following the arrest of a Syrian accused of belonging to a jihadist group. STR-/AFP/Getty Images

“What is happening today is among the most dangerous of what Lebanon and the Lebanese are being subjected to,” the army statement said. “The gunmen kidnapped several soldiers and policemen who were spending the weekend with their families … and demanded the release of some of the most dangerous detainees held by the army.

“The Lebanese army will not accept that its members be hostages and will not stay silent about targeting the army and Arsal residents.”

The statement said the Lebanese army “will not allow any side to move the battle from Syria” into Lebanon. It added that the army “will not allow any foreign gunman to endanger the security of Lebanon or to harm its soldiers or policemen.”

The Lebanese army general said earlier in the day that gunmen took two soldiers who were driving an army tanker truck. The army’s later statement said the two soldiers were later freed in an army operation.

The general and the official spoke on condition of anonymity as they weren’t authorized to speak publicly.

Prime Minister Tammam Salam described the attack as a “flagrant aggression against the state of Lebanon” and vowed that his government “will deal with the developments with extreme firmness and strength.”

Saturday’s attacks came hours after the army said troops detained Syrian citizen Imad Ahmad Jomaa, who identified himself as a member of Syria’s al-Qaida-linked Nusra Front. The National News Agency said Jomaa was detained as he was being brought to a hospital in Lebanon after being wounded while fighting Syrian troops.

A resident in Arsal told the AP that masked gunmen roamed the streets. The man, who asked not to be identified for fear of reprisals, said two shells hit a small Syrian refugee camp in the town, sparking a fire.

“Clashes are continuous and people are staying in their homes,” the man said by telephone as cracks of gunfire could be heard in the background. “Arsal is under the control of gunmen who are driving around.”

Arsal is home to tens of thousands of Syrian refugees and rebels enjoy wide support among its population. Lebanese Sunnis, such as the residents of Arsal, often back the Sunni rebels fighting against Syrian President Bashar Assad. Shiites, like those belonging to Lebanon’s Hezbollah militant group, typically back Assad.

Lebanese and foreigners light candles during a vigil calling for the release of Italian Jesuit priest Father Paolo Dall’Oglio, who was kidnapped in Syria, at the St. Joseph Church in Beirut, Lebanon, Tuesday, July 29, 2014. (AP Photo/Bilal Hussein)

Syria’s civil war has spilled over into Lebanon on multiple occasions and inflamed sectarian tensions leaving scores dead. However, previous rebel raids never went so deeply into Lebanese territory.

The Islamic State group, a powerful extremist rebel group in Syria, recently seized large swaths of territory in neighbouring Iraq. It wasn’t immediately clear whether the gunmen in Arsal intended to remain in the town, which is surrounded by Shiite villages where Hezbollah is active.

The violence in Arsal came after an ambush near Syria’s border with Lebanon killed dozens of opposition fighters, activists said. The Britain-based Syrian Observatory for Human rights said Syrian troops and members of Lebanon’s Hezbollah group ambushed opposition fighters in the Qalamoun region near the Lebanese border, killing at least 50 of them. It said seven troops and Hezbollah fighters were killed in the fighting.

Government troops backed by Hezbollah fighters have seized nearly all the strategic Qalamoun region since launching an offensive there last November, severing rebel supply lines from neighbouring Lebanon.

The Syrian uprising began in the form of peaceful protests against President Bashar Assad in March 2011, but escalated into an insurgency when government forces violently cracked down on dissent. Over 170,000 people have been killed in Syria in more than three years of fighting, activists say.