The encampment was attacked from a bridge over the river Chenab, close to the industrial city of Wazirabad, less than 150 kilometres (100 miles) southeast of the capital.
Hours earlier, thousands from the Defence Council of Pakistan coalition of right-wing and hardline Islamist groups crossed the bridge on a "long march" from Lahore to Islamabad to protest against the reopening of NATO supply routes to Afghanistan.
Pakistan is battling an Islamist insurgency in its lawless northwest tribal region, but attacks in the area of Monday's incident, in the prosperous and generally peaceful province of Punjab, are unusual.
"At least seven security personnel including a police official embraced shahadat (martyrdom) and five others were injured due to firing by unknown assailants near Wazirabad," the military said in a statement.
A military rescue party had camped by the Chenab to look for the body of a pilot missing in a helicopter crash in May, the statement said, and the camp came under attack from a bridge.
"The exact number of attackers is not known but they came by motorbike and sprayed bullets on the troops from the bridge," a senior security official told AFP on condition of anonymity.
"It is highly likely that the attackers belonged to a banned religious outfit, which is a hand in glove with Taliban."
The official added: "Nobody has so far claimed responsibility of the attack but if we follow the pattern of the attack, it looks similar to assaults that these outfits have been carrying out in different cities."
The convoy of thousands travelling by bus, truck and car with the protest march stopped for the night in the town of Gujrat, across the river Chenab from Wazirabad, and they were expected to reach Islamabad on Monday afternoon.
The Defence Council of Pakistan bitterly opposes the country's "war on terror" alliance with Washington and the reopening of overland routes for trucks supplying NATO troops fighting the Taliban in Afghanistan.
Hafiz Mohammad Saeed, the founder of the banned Islamist group Lashkar-e-Taiba blamed for the 2008 attacks in Mumbai, who has a $10 million US government bounty on him, on Sunday urged Pakistanis to join the protest.
The prime minister's adviser on interior affairs Rehman Malik said Sunday an elaborate security plan had been put in place for the march, involving four surveillance helicopters and closed-circuit cameras to monitor proceedings.
Pakistan reopened its roads to NATO convoys last week after closing them in protest at a US air raid that killed 24 Pakistani soldiers in November.
The air raid plunged ties between the Islamabad and the United States, already shaky after the US raid that found and killed Osama bin Laden in a Pakistani garrison town in May 2011, to a new low.
After months of negotiations, a rapprochement was achieved when US Secretary of State said sorry for the deaths in the air raid.