BAGHDAD — Iraqi airstrikes pounded a town near Fallujah that had been seized by al-Qaida linked militants and commandos swept in Wednesday to clear the area, senior military officials said. It was a rare victory for government forces that have been struggling for nearly three weeks to regain control of the mainly Sunni area west of Baghdad.

North of the capital, a bomb tore through a funeral of an anti-al-Qaida Sunni militiaman, the deadliest in a series of attacks that killed at least 50 people nationwide.

Violence has risen sharply as extremist Islamic militants try to exploit growing anger among the Sunni minority over what they perceive as mistreatment and random arrests by the Shiite-led government.

Members of the al-Qaida linked group known as the State of Iraq and the Levant — emboldened by successes in the civil war raging next door in Syria — made a push to seize parts of the mainly Sunni Anbar province as violence erupted after the government arrested a Sunni lawmaker sought on terrorism charges on Dec. 28, then dismantled an anti-government Sunni protest camp in the provincial Ramadi.

Prime Minister Nouri al-Maliki has held off ordering an all-out offensive against the extremists because of fears that civilian casualties could incite Sunni anger and push moderate tribal leaders to side with the extremists. The area was one of the bloodiest battlefields for U.S. forces during the war and al-Qaida’s resurgence poses a major challenge to the government and its forces two years after the Americans withdrew.

Wednesday’s counterattack came a day after al-Qaida militants blew up an explosives-laden fuel tanker at an army checkpoint, killing three soldiers, on a small bridge near Saqlawiya, just north of Fallujah.

Heavily armed gunmen then stormed into the town and surrounded the main police station, forcing all the policemen to relinquish their weapons and leave. Security forces then launched airstrikes against the gunmen, who fled, allowing Iraqi troops to enter the town later Wednesday.

The senior military officials described the events on condition of anonymity because they weren’t authorized to release the information.

It was a welcome success for Iraq’s government, which has been heavily criticized for failing to protect the people. But the militants retain control of large swaths in Ramadi and Fallujah.

The unrest in Anbar and other mainly Sunni-dominated provinces has uprooted thousands of people from their homes as they flee the fighting amid fears the government may still launch an all-out offensive.

International aid agencies appealed to the warring parties on Wednesday to allow humanitarian aid to reach the displaced families.

More than 11,000 families have fled their houses in Fallujah and Ramadi to either nearby areas or outside Anbar province, according to the U.N. Some of these families have ended up in abandoned buildings, schools and half-built houses while others ended up with relatives.

The World Health Organization said the few health facilities in the province were no longer able to provide even lifesaving interventions and residents in Ramadi and Fallujah face acute health needs due to the conflict. The organization said it has dispatched 2 tons of medicine and supplies.

The International Committee of the Red Cross said it has delivered food and essential supplies over the past few days to nearly 12,000 displaced people in Anbar and several other mainly Sunni areas. It warned the families “are enduring considerable hardship,” and their situation has shown no signs of improvement.

Rashid Hassan, an ICRC delegate who participated in a distribution of aid in the northern province of Tikrit, said that in one instance 65 people, including many children, were crammed into one four-room house. “People are struggling hard to cope with the cold as blankets, mattresses and food are lacking,” he said.

Fallujah resident Omar al-Mohammadi had to take his six-member family outside the city 10 days ago, fearing for their safety amid clashes between security forces and gunmen.

The family settled in a big store owned by his brother in Saqlawiya.

“We lack fuel, electricity and we have only few blankets to protect us from the cold weather,” said al-Mohammadi, a government employee.

Unable to work, he is drawing on his savings to buy expensive fuel and foodstuff for his wife, son and three daughters.

“Our situation is getting worse, but we have no choice but to endure instead of getting killed in the fighting,” he said, adding he has no plans to return to Fallujah as long as the situation remains “ambiguous.”

Meanwhile, Iraqi Prime Minister Nouri al-Maliki warned that the battle against al-Qaida militants in Anbar would not be easy.

“The battle will be long and will continue,” al-Maliki said in his weekly televised speech. He also urged tribal allies in Anbar to continue fighting on the government’s side.

He urged Anbar tribal allies to continue fighting al-Qaida, adding that “The tribesmen should take a firm stance in order to expel the terrorists from their areas so that peace would prevail there.”

Tensions also are high elsewhere, raising fears that Iraq is being pushed back toward the sectarian bloodshed that killed tens of thousands of people following the 2003 U.S.-led invasion that ousted Saddam Hussein.

The funeral bombing occurred in the town of Buhriz, 60 kilometers (35 miles) north of Baghdad, killing 16 people and wounding 26 inside a mourning tent, according to security and health officials.

The funeral was for an anti-al-Qaida Sunni militiaman who died of natural causes two days ago. The Sunni militia, known as the Awakening Council, was formed by U.S. forces during the height of the insurgency. They are seen as traitors by al-Qaida’s local branch and other militant groups.

In Baghdad, bombings killed at least 28 people, including two that targeted outdoor markets and several car bombings in the mainly Shiite areas, according to officials. Nobody immediately claimed responsibility for the attacks, but they bore the hallmarks of al-Qaida and other Sunni insurgents.

A roadside bomb also hit a military convoy near the northern city of Mosul, killing six soldiers and wounding eight others, officials said.

Medical officials confirmed the causality figures. All officials spoke on condition of anonymity as they were not authorized to release information.