PESHAWAR (Agencies) - Hundreds of foreign militants attacked Pakistani forces near the border with Afghanistan, sparking clashes that left seven soldiers and 48 militants dead, the military said Sunday. The fierce fighting began late Saturday and continued early Sunday in Mohmand tribal area, the military said in a statement. The cross-border attack was the biggest in recent months against Pakistan's security forces, who are battling to flush out militants in several areas of the country's northwest. Most of the insurgents came from the Afghan side of the border and were joined by local Taliban fighters. The combined force of about 600 militants then attacked a Frontier Corps base near the border. The militants, armed with mortars, rocket-launchers and grenades, attacked the fort at Mamad Gate - where members of Pakistan's elite Quick Reaction Force were stationed - from several directions, officials and witnesses told AFP. "Frontier Corps troops repulsed a massive attack by militants on one of its locations in the area," the military said in a statement, adding that 'severe fighting continued through the night'. Residents told AFP the bodies of militants were left on the ground in the area. Seven soldiers were wounded in the gunbattles, the military said, adding that paramilitary troops 'inflicted heavy casualties' on the militants, without giving a toll for the enemy wounded. Most of the attackers fled under heavy military fire, a security official told AFP. Some of the fighters surrendered, a military spokesman said later, without giving a specific figure. Sporadic gunbattles continued for a few hours early Sunday, the military said. Residents saw helicopters overhead but officials did not say if they had attacked rebel positions. Security forces sealed all roads in the area and also in the neighbouring Bajaur tribal area, where the military is also battling militants, residents said. Islamabad and Kabul have been unable to rein in the extremists that have been holed up in Pakistan's tribal areas since they fled Afghanistan after the US-led invasion that drove out the Taliban government in late 2001. Last week, Afghan President Hamid Karzai said during a visit to Kabul by his Pakistani counterpart Asif Ali Zardari the two countries had a 'new relationship' and determination to defeat terrorism and extremism together. Karzai had previously accused Islamabad of not doing enough to shut down militant 'sanctuaries' in the tribal badlands and stop insurgents from crossing into Afghanistan. Pakistan rejected those accusations, pointing to its operation in Bajaur, which borders Mohmand and Afghanistan. The military says more than 1,500 rebels have been killed there since August.