NEW DELHI, JULY 18 -- The government today imposed direct federal rule in Kashmir, where Indian security forces are battling to put down a rebellion by Moslem separatists.

The action follows the killing Tuesday of at least 29 Moslem militants by Indian security forces.

In the Pakistani capital of Islamabad, meanwhile, India and Pakistan opened negotiations today aimed at repairing relations threatened by the rebellion in the disputed northern region.

Relations between Pakistan and India worsened in January when Indian soldiers cracked down on Moslem militants in Kashmir. The militants are seeking independence from India or union with Pakistan, and at least 792 people have been killed in Kashmir since the crackdown. India has accused Pakistan of arming and training the militants, a charge Pakistan has denied.

Before direct federal rule was imposed today on Jammu-Kashmir state, it had been administered temporarily by a governor, a federal representative, since Jan. 18. The announcement of federal rule reflected the belief that Jammu-Kashmir state was too unstable to be run by an elected local government.

The 29 militants were killed by Indian security forces in Kashmir, the Moslem-dominated northern part of Jammu-Kashmir state and the center of the secessionist campaign.

Officials, who could not be identified under briefing rules, said 21 militants were killed in a battle with the Border Security Force in Poonch, 400 miles northwest of New Delhi. Hours later in the same area, troops killed eight militants who slipped across the border from Pakistan, the officials said.