BAGHDAD — Al-Qaida briefly planted its flag in Baghdad on Thursday as militants killed 23 members of Iraq’s security forces across the country in a combination of shootings and roadside bombs demonstrating the dangers the country still faces.

The worst attack came in Baghdad’s Sunni neighborhood of Azamiyah when 16 Iraqi security forces were killed by what appeared to have been coordinated strikes by al-Qaida militants, who then planted their flag close to the blood-soaked site.

The daylight attack on the northern district, once an insurgent stronghold, suggests the insurgents are looking to regain a foothold in the capital as the U.S. military presence diminishes and Iraqi security forces struggle to keep the peace without the promise of American backup.

Militants attacked an Azamiyah checkpoint and then set it on fire, burning several soldiers’ bodies, according to an army officer who was on patrol in the neighborhood. Attackers then detonated three roadside bombs nearby, the officials said.

A large pool of blood and what appear to be char marks could be seen on the ground near an Iraqi army truck. Authorities immediately sealed off the area.

The Azamiyah attack came in what was already a deadly day for Iraq’s security forces, which are increasingly being targeted by insurgents as all but 50,000 U.S. troops prepare to leave the country by the end of August.

All American troops are set to leave Iraq by the end of 2011.

Earlier Thursday, a suicide bomber drove a minibus into the main gate of an Iraqi army base near Saddam Hussein’s hometown north of Baghdad, killing four soldiers and wounding 10, said police and hospital officials.

In Fallujah, 40 miles west of Baghdad, two roadside bombs targeting Iraqi army patrols killed two soldiers and wounded eight others, police and hospital officials in the city said.

In Mosul, a bomb attached to a police vehicle killed one policeman and injured two others, a police official said.

All officials spoke on condition of anonymity because they were not authorized to speak to the media.