At least five Central Reserve Police Force (CRPF) jawans were killed and seven others were injured as militants stormed into a camp of the forces in Srinagar's Benima area on Wednesday morning, officials said.
The two militants, who were dressed in cricket uniforms, were killed.
The militants threw grenades and fired indiscriminately after attacking the camp, reports said.
The CRPF camp is located near a school.
Reacting to the attack, Union Home Secretary RK Singh said prima facie evidence suggested that the militants came from Pakistan.
"Prima facie evidence suggests that these militants were from across the border. They were probably from Pakistan," Singh told reporters.
No militant group has claimed responsibility for the attack so far.
Making a brief statement on the attack, Jammu and Kashmir Chief Minister Omar Abdullah said in the state Assembly: "Today, five CRPF jawans were killed and four to five were injured in the fidayeen (suicide militants) attack at a CRPF camp in Srinagar at 10:45 am."
Jammu and Kashmir´s main opposition Peoples´ Democratic Party (PDP) has condemned the attack.
"We condemn this attack...Violence is not going to solve anything," PDP president Mehbooba Mufti told media.