Pakistan was racing Tuesday to help refugees fleeing a military offensive against the Taliban in a northwestern valley — an exodus of some 1.5 million of a speed and size the U.N. said could rival the displacement caused by Rwanda's genocide.

The humanitarian challenge comes as the military said more than 30 militants and soldiers died as troops tried to re-conquer key towns in the Swat Valley and clashed with insurgents near the Afghan border.

Lt. Gen. Nadeem Ahmed, who leads a group tasked with dealing with the uprooted Pakistanis, said the government had enough flour and other food for the displaced but said it needed donations of fans and high energy biscuits. He also said the refugees would get money and free transport when it was safe enough to return.

A "camp is not a replacement for home," Ahmed told reporters, adding there are at least 22 relief camps operating.

The U.S. has praised Pakistan's military operation in Swat and surrounding districts, which comes amid long-standing American pressure to root out Al Qaeda and Taliban hide-outs along the border with Afghanistan. Militants in those sanctuaries threaten American and NATO troops in Afghanistan and Pakistan's own future, U.S. officials warn.

On Tuesday, the army said its operation to clear Swat was "making headway as planned."

Troops were engaged in firefights in the towns of Matta and Kanju and near a strategic bridge as well as battling militants in the Piochar area, the stronghold of Swat Taliban chief Maulana Fazlullah, a military statement said.

Sixteen militants and four soldiers were killed, while 16 more troops were wounded, it said.

A separate statement from the paramilitary Frontier Corps said troops killed 13 more militants in the Mohmand frontier region. It said the dead included three Libyans and a Saudi, but gave no details about them.

Pakistan says more than 1,000 militants have been killed since the offensive began in late April, a claim impossible to verify because journalists have largely been barred from the battle zone. Officials have given no figures for civilian casualties, but refugees say they have occurred.

Whether Pakistan's will to take on militants entrenched across the northwest will falter could depend on the fate of the multitude of displaced citizens, many now stuck in the sweltering camps.

U.N. officials said Monday that nearly 1.5 million people had fled their homes in Pakistan this month.

"It has been a long time since there has been a displacement this big," Ron Redmond, a spokesman for the U.N. refugee agency.

Earlier offensives had caused another 550,000 people to flee, though Ahmed said Tuesday that 230,000 people had returned to Bajur, a tribal region overrun by the Taliban and targeted in a lengthy military operation.

In trying to recall another such displacement in so short a period, Redmond said, "it could go back to Rwanda" — a reference to the 1994 massacre of ethnic Tutsis by the majority Hutus in the African country. The genocide displaced some 2 million people.

The U.N. refugee agency says it has registered 130,950 people in the camps. Many others are staying with relatives, host families or in rented accommodation.

Redmond, speaking in Geneva, said failure to help the displaced and the many thousands of families hosting them could cause more political destabilization in the country.