For months, Islamic State militants rampaged across Syria and Iraq, seizing cities, taking hostages and terrorizing all who dared to confront them.

The tide began to turn in mid-August, when U.S. airstrikes pushed them from key Iraqi battlegrounds. Then, on Aug. 19, the group released a video that showed the beheading of American freelance journalist James Foley.

The pattern continued.

Within days of a military defeat, the group would release images of more beheadings — at least nine over six weeks — of Western journalists, aid workers and Muslim soldiers.

The tactic signals that even as the Islamic State group suffers battlefield losses, it is holding on to its edge in the propaganda war. U.S. officials say that's the only way the militants can continue to maintain support and attract new recruits.

On Friday, the Islamic State group released a new video showing the beheading of British aid worker Alan Henning after nearly two straight weeks of daily airstrikes against their fighters.

"Certainly since the bombing campaign, the reverses, they're no longer boasting of taking places — because they're not taking places. They're losing places," Alberto Fernandez, who heads the State Department's office for counterterrorism propaganda, said in a recent interview. "So what do they do? They boast about cutting people's heads off. They're trying to substitute that for military victory."

That may be some propaganda by the U.S itself. But the trend still is frightening, considering the Islamic State group is holding what U.S. intelligence officials believe are as many as 20 hostages, including at least two Americans.

This past week, the militants suffered a series of setbacks, with U.S. and allied airstrikes Friday hitting Syrian oil refineries and a training camp. Earlier strikes pushed militants back from some of their positions in Iraq.

But the Islamic State group this past week also besieged the Iraqi town of Hit and ambushed an Iraqi army unit north of Ramadi, kept its tight grip on Fallujah, and closed in on the Syrian town of Kobani.

In the video of Henning's beheading, a masked militant warns the U.S. that the gruesome attacks on individuals will continue as long as the airstrikes do. He also threatened that an American hostage, identified as Peter Kassig, would be next. "It is only right that we continue to strike the neck of your people," masked militant said.

Violence has been a focal point of Islamic State group propaganda, to show the militants' might and recruit the thousands of foreign fighters who have rushed to join them. When they captured Mosul, Iraq, in June, they beheaded security forces, raped women and terrorized residents into following an extreme form of Islamic law known as Sharia.

But the group had held Western hostages for months and, in some cases, even years. Not until the airstrikes began, weakening the group's momentum, did the extremists start beheading the white Westerners.

In the Foley video, an unidentified fighter warned that American journalist Steven Sotloff would be next if the U.S. campaign did not stop. The airstrikes continued, and Sotloff was beheaded in a video released Sept. 2, two days after the U.S. helped force the Islamic State group from Amirli, Iraq.

From Sept. 7-9, U.S. airstrikes pounded militant positions around Haditha, Iraq. On Sept. 11, British Prime Minister David Cameron announced that his government was considering using air power against the Islamic State group in Syria.

On Sept. 13, the Islamic State group released a video of the beheading of British humanitarian aid worker David Haines. The unidentified killer said Haines was paying the price for Britain's decision to supply weapons to Kurdish peshmerga fighters, and he mentioned the Haditha strikes.

The group has released videos or pictures of beheadings of Kurdish fighters, including several recently captured in clashes near the Syria-Turkey border. All the images came out after the Islamic State group was attacked or suffered setbacks in Kurdish areas in northern Iraq and Syria.

The group "wants to create the impression of victory and demoralize its Kurdish enemies," the Clarion Project, a Washington-based organization that tries to counter Islamic extremism, said in an Aug. 28 alert about the beheading of a Kurdish soldier.

The militants also claim to have beheaded two Lebanese soldiers kidnapped during a raid of the Lebanese border town of Arsal in August. One of victim was a Sunni Muslim; that's important because it belies Islamic State propaganda that it is creating a religious empire, or caliphate, for faithful Sunnis.

The group is trying to turn some of its tactical defeats into strategic victories.

By highlighting the airstrikes' reported civilian casualties, the militants are trying to rally Syrian Sunnis who have suffered during the civil war. Much of the Islamic State propaganda notes that the United States and the West have not helped Sunnis in Syria or in Iraq, where they were sidelined from power and in some cases targeted by the Shiite government of former Prime Minister Nouri al-Maliki.

In a Sept. 22 statement, the day after the first U.S. airstrikes on Syria, the London-based Islamic Human Rights Commission called on the Islamic State group to release Henning but also urged Muslim leaders "not to forget the many innocents who continue to be slaughtered on a daily basis."

Juan Zarate, a deputy national security adviser on counterterrorism to President George W. Bush, said it was "a very difficult balance" for the U.S. and its allies as they weigh the safety of their kidnapped citizens against continued attacks on the militants.

"What you try to do is find ways to accelerate potential releases, or acquisition of where (the hostages) are, and have that as part of your battle plan considerations," Zarate said. "But once you've made the decision to engage the enemy, and they have your citizens, you're taking a risk. And lives are going to be lost."

___

Follow Lara Jakes on Twitter at: https://twitter.com/larajakesAP