The slain militants were identified as Salim alias Adil Pathan and Rehman alias Burmi, police sources said, adding they were suspected to be Pakistani nationals.
The encounter erupted after a joint team of police and army cordoned off Hari village in Tral in Pulwama and started a search operation following an intelligence input, police said.
As the search operation was going on, the militants, who were hiding in the area, tried to break the cordon and opened fire on the forces, Superintendent of Police (SP), Awantipora, Irshad Ahmad, told PTI.
Army said a soldier was injured in the encounter.
Also Read
"One Army soldier who sustained a gunshot wound was immediately evacuated and his condition is reported to be stable," an army spokesman said.
He said the operation led to the recovery of two AK-47 rifles and other "war-like stores", including a grenade, four magazines and 80 bullets.
Police said the killed militants were instrumental in motivating and recruiting local youth to join militancy.
The duo had also tried to create impediments in last year's elections and were involved in planning attack on minority pickets, a police spokesman said.
They were involved in the kidnapping of two persons in 2014, the spokesman said, adding the slain militants were also involved in many unlawful activities on the directions of Pakistan-based commanders.
Pakistan-based JeM has been responsible for several major attacks in Jammu and Kashmir and Delhi, including the one on Parliament on December 13, 2001.
The outfit was founded by Masood Azhar, one of the three terrorists released in exchange of passengers and crew of the hijacked Indian Airlines plane in December 1999.