The army said after about two hours of an intense gun battle that the firing had stopped and that the situation was "contained and under control."
In the middle of the night, said sources, it was difficult to ascertain whether the terrorists, believed to be about three to four in number, may have fled. A search and cordon operation is now on in the area to secure it.
The terrorists attacked the 46 Rashtriya Rifles camp of the army and the adjacent BSF camp in main town Baramulla in two groups at about 10.30 pm on Sunday. Heavy firing and loud grenade blasts were heard.
Sources said the attackers managed to enter the fringes of the BSF camp. They are suspected to have entered India across the Jhelum river.
Two weeks ago, four Pakistani terrorists had sneaked into an army base in Uri, also in Baramulla district, and killed 19 soldiers. Security forces have been on high alert since the Uri attack.
On Thursday last week, the Indian Army said it had conducted surgical strikes across the Line of Control against teams of Pakistani terrorists waiting to infiltrate into India with the aim of attacking various places in Jammu and Kashmir and also several metros.