BAGHDAD, Iraq -- More than 40 Syrian soldiers who had sought temporary safety in Iraq from rebel fighters along the border were killed on Monday in an attack by unidentified gunmen as the Iraqi military was transporting the soldiers back to Syria in a bus convoy, the government said. At least seven Iraqis were also reported killed in the attack, which appeared to be the most serious spillover of violence into Iraq since the Syrian conflict began two years ago.
Ali al-Musawi, a spokesman for Prime Minister Nuri Kamal al-Maliki, accused "armed groups from the Iraqi and Syrian side" of coordinating the attack, which he described as an ambush. He said Iraq would deploy more security forces on the border. Middle East experts said such a move raised the risk that the Iraqis could become more directly enmeshed in the Syrian conflict, underscoring how it threatens to destabilize a wider swathe of the region.
"We will not allow any terrorist to enter the Iraqi lands," Mr. Musawi said in a telephone interview. He said the ambush was partly the consequence of "sectarian speeches that encourage people to hate each other."
Mr. Musawi did not specify which armed groups he was alluding to, but it was clear that he meant Sunni militant extremists affiliated with Al Qaeda in Iraq. These groups have become increasingly emboldened by popular Sunni resentment against Mr. Maliki, a Shiite who is accused by critics of trying to marginalize Iraq's Sunni population since the American occupation of Iraq ended in 2011.
The Al Nusra Front, a Sunni insurgent force in Syria that has become known for its audacious attacks on government targets, has links with Al Qaeda in Iraq, and American officials have blacklisted it as a terrorist organization. But many Iraqi Sunnis sympathize with the Syrian insurgents, who are overwhelmingly Sunni and whose clan relations span national boundaries.
"A number of us have been saying that Iraq is the one most affected by the meltdown in Syria," said Joshua M. Landis, director of the Center for Middle East Studies at the University of Oklahoma and curator of the Syria Comment blog, which has chronicled the Syrian conflict.
"In that region, the tribes go right across the Syrian border, and most of the people are related by blood," he said. "They're in one common struggle."
Mr. Maliki has not expressed outright support for President Bashar al-Assad of Syria, whose minority Alawite sect is an offshoot of Shiite Islam. Mr. Assad's allies in the region are the government of Iran, which is majority Shiite, and Hezbollah, the Shiite militant group that is a powerful political force in Lebanon.
But last week, Mr. Maliki warned that a victory for the Syrian insurgency could create a Sunni extremist haven in Syria and incite sectarian mayhem in his own country as well as in Lebanon and Jordan. All three countries, along with Turkey, are hosts to hundreds of thousands of Syrian refugees, mostly Sunnis.
According to accounts from Mr. Musawi and other Iraqi officials quoted by Western news agencies, the ambushed Syrian soldiers originally crossed into Nineveh Province, Iraq, over the weekend to escape attacks by insurgents at the Yaarubiyeh border crossing. In returning them, Iraqi soldiers put the Syrians on a bus headed for a different border post, in Anbar province, partly to avoid the same hostilities the Syrians had fled.
But the bus, part of an Iraqi military convoy, was attacked as it neared the al-Waleed crossing by gunmen armed with mortars, automatic weapons and improvised bombs, who appeared to have advance knowledge of the convoy route. Agence France-Presse quoted an Iraqi army officer, Lt. Col. Mohammed Khalaf al-Dulaimi, as saying that at least three vehicles were destroyed.
The Syrian state-run news agency SANA made no immediate mention of the ambush, but it quoted Mr. Maliki as saying he supports a peaceful solution of the Syrian conflict and that "vandalism and the use of arms will lead nowhere."
News of the ambush came as Syrian rebel fighters claimed other gains against the government on Monday, notably the seizure of the contested north-central city of Raqqa following days of heavy clashes. Rebel videos uploaded on the Internet showed activists smashing a statue of President Assad's father, Hafez, in the central square to punctuate their victory.
The Syrian Observatory for Human Rights, a Britain-based group with a network of contacts in Syria, quoted a lawyer in Raqqa as saying the rebels had captured the provincial governor, Hasan Jalali, and the secretary general of the Raqqa branch of Mr. Assad's ruling Baath Party, Suleiman al-Sleiman. If confirmed, they would be among the highest-ranking officials detained by insurgents.
It was unclear late Monday whether the insurgents could retain control of Raqqa, a strategic city on the Euphrates River. But if they can, it would be the first provincial capital completely taken over by the armed resistance. For the government, the loss of Raqqa would diminish the prospects that Mr. Assad's military, now fighting on a number of fronts, could retake large areas of northern and eastern Syria from the rebels.
An activist reached by phone in Raqqa, Abu Muhammad, said: "The only place still under control of the regime, in the entire province of Raqqa, is the military security building."
Earlier Monday, anti-Assad activists reported heavy fighting in Homs between rebels and government forces backed by tanks and warplanes.
The clashes in Homs, a central Syrian city that had been quiet recently, seemed to shift attention from the northern city of Aleppo, where fighting had swirled for days around the Khan al-Asal police academy. Both sides in the civil war, which has claimed an estimated 70,000 lives, acknowledged relatively high death tolls there.
The pro-government Al-Watan newspaper accused opposition fighters on Monday of massacring 115 police officers and wounding 50 at Khan al-Asal. On Sunday, the Syrian Observatory for Human Rights said 200 government soldiers and rebels had been killed.
In an interview published in The Sunday Times of London, Mr. Assad assailed Britain's suggestion that it may provide more than just nonlethal aid to his enemies. He also restated his opposition to peace talks with armed insurgents.
"How can we ask Britain to play a role while it is determined to militarize the problem?" Mr. Assad said. "How can we expect them to make the violence less while they want to send military supplies to the terrorists?"
William Hague, Britain's foreign secretary, said Mr. Assad's remarks "will go down as one of the most delusional interviews that any national leader has given in modern times."
Duraid Adnan reported from Baghdad, and Rick Gladstone from New York. Reporting was contributed by Hania Mourtada from Beirut, Lebanon, Alan Cowell from London and a New York Times employee from Damascus.
This article originally appeared in The New York Times.