Five soldiers were injured in the pre-dawn attack, officials said.
TV news channels reported that the security personnel were attacked by a group of gunmen shortly after they had offered their morning prayers.
The gunmen, who were using cars and motorcycles, fled after the shooting. The military confirmed the incident and the casualties in a brief statement.
It said seven security personnel, including a police official, were killed and five others were injured "due to firing by unknown assailants near Wazirabad", a town located 12 km from Gujrat city.
The security personnel were part of a small rescue party that had camped on the bank of the Chenab river to search for the body of a pilot mission since a military helicopter crashed on May 23, the statement said.
The injured persons were taken to the nearest military hospital in Gujranwala district, the statement said.
No group claimed responsibility for the incident.
The attack occurred hours after thousands of supporters of the Defa-e-Pakistan Council arrived in Gujrat as part of a "long march" to protest the government's decision to reopen NATO supply routes to Afghanistan.
The DPC is an alliance of over 40 religious and extremist groups, including the Jamaat-ud-Dawah and the banned Sipah-e-Sahaba. The DPC is opposed to the transportation of supplies for foreign troops in Afghanistan through Pakistani territory.
The supply routes were closed last November after a cross-border NATO air strike killed 24 Pakistani soldiers.
The government reopened the supply lines last week after the US apologised for the NATO attack.