Police say the men killed four security officers and wounded at least 12 other people before being killed themselves. 

The attack on Friday came on the eve of a rare trip to Pakistan by Indian Prime Minister Atal Behari Vajpayee, who is due to attend a January 4-6 South Asian summit there. The nuclear-armed rivals have fought two of their three wars over Kashmir.

"The gunfire has ended. Both the militants have been killed, but the search operations are still going on," said a senior police officer in Jammu.

Hundreds of passengers were in the Jammu station at the time of the evening attack. Police surrounded the station and began evacuating it.

It was the latest of almost daily attacks by separatist rebels who have been fighting Indian rule in the Muslim-majority state since 1989 in a rebellion that has killed more than 40,000 people.

Indian accuses Muslim Pakistan of backing the rebels.

Pakistan denies it foments violence and has repeatedly called for talks to resolve the dispute.