BEIRUT, Lebanon — Gunmen who crossed into northeastern Lebanon from Syria attacked several army checkpoints in a border town on Saturday in what appeared to be an effort to win the release of a Syrian rebel who had been detained by Lebanese troops.

Initial reports from the town, Arsal, described a chaotic situation involving multiple attacks on checkpoints, security posts and homes and also the seizure of some members of the security forces by the gunmen, identified as rebel fighters from across the border in Syria.

The town’s mayor, Ali al-Hujeiri, reached by phone, said that two civilians had been killed while trying to help repel attacks by the gunmen on security checkpoints, adding that a total of nine checkpoints had been hit. Lebanon’s National News Agency reported that two soldiers and two civilians had been killed.

The Lebanese Army said in a statement that the gunmen had also attacked homes in Arsal and captured an unspecified number of soldiers who were on leave, possibly for use in a detainee swap. A security official, who spoke on the condition of anonymity because he was not authorized to speak to the press, said two soldiers had been seized by rebels but then freed by fellow soldiers. Later in the day, the army confirmed that the soldiers had been freed.