Updated

Hundreds of Pakistanis lugging bags and bundles of clothes fled a northwestern town Sunday after pro-Taliban tribesmen and foreign militants battled security forces in clashes near the Afghan border that left at least 53 people dead.

The fighting, which started Saturday and largely died down early Sunday, was the worst in two years in the lawless North Waziristan region, where well-armed, fiercely independent tribes have long resisted government control.

Army spokesman Maj. Gen. Shaukat Sultan said sporadic gunfire broke out Sunday afternoon in Miran Shah, the main hotspot of the unrest. But the fighters retreated from government buildings they had occupied, and soldiers controlled the town again, he said.

Sultan said foreigners involved in the fighting had come from neighboring Afghanistan and would be "confronted and eliminated."

The fighting came as President Bush made a 24-hour visit Saturday to the capital of Islamabad, about 190 miles northeast of North Waziristan, and declared his solidarity with Pakistan in the war on terror.

Sultan said at least 46 fighters and five soldiers were killed in the fighting.

Miran Shah's hospital said two civilians were killed — a 25-year-old man who died when a shell hit his home and a 50-year-old homeless man.

The fighting came just days after the army attacked a suspected al-Qaida camp in the village of Saidgi near the Afghan border.

Waziristan is known as a hotbed of al-Qaida and Taliban militants who draw support from the local Pashtun tribal people. Many of the rebellious tribesmen involved in Saturday's unrest are believed to be Islamic students, referred to as "local Taliban," reflecting their sympathies with the hardline militia in Afghanistan.

Miran Shah's streets and bazaars were empty. Smoke billowed from a bank building hit by an artillery shell. Another shell tore a hole in the home of a doctor who lived on the premises of a state-run hospital. Shells also pocked the side of the hospital.

Both sides were using mortars and other heavy weapons, and it was not known who hit the buildings or whether they were targeted or hit by accident.

Security forces fortified themselves inside a heavily guarded base Sunday after the fighting died and troops fired into the air if anyone came within 300 yards.

Hundreds of villagers — men, women and children — were seen fleeing Miran Shah on foot Sunday, carrying suitcases and bundles of clothes. Vehicles weren't allowed in or out of the town, so they had to walk nine miles to a security checkpoint, where they could find transport.

Noor Nawaz, 25, who runs a shop selling auto parts, said he and his family spent a sleepless night because of the fighting. Mortar and artillery fire thundered overnight, and helicopters could be heard flying until dawn.

"People are extremely scared. Nobody has slept. Children were crying," he said as he fled from the town with his wife and three children. His veiled wife was carrying their 3-year-old son.

Intercepts of radio communications between militants Saturday in Miran Shah and nearby Mir li suggested 80 or more fighters had died, security and intelligence officials said.

A man who claimed to speak for the militants called The Associated Press by satellite phone from an undisclosed location and said that fighters killed 55 soldiers and captured 14 others, but that could not be verified.

The purported spokesman, Maulvi Abdul Ghafoor, warned that fighting will spread to other areas of the region if troops do not withdraw.

Pakistan has deployed about 80,000 security forces along the Afghan frontier, but has failed to assert the government's control in these tribal regions which have resisted outside influence for centuries.