The recovery of the bomb came to light at a time when security forces were maintaining tight vigil ahead of Independence Day.
On getting information about a bomb on the train, the Government Railway Police (GRP) stopped it at Akbarganj Railway Station, ADG (Railways) BK Maurya said.
Akbarganj is around 70 km away from state capital Lucknow.
"The entire train was vacated and extensively checked during which a bomb wrapped in 'sutli' (jute thread) was found in a packet with two lighters. It seems an attempt was made to prepare a crude device. It could not have exploded on it own," the ADG said.
"It seems someone is playing mischief. We have alerted all railway stations," Maurya said.
The train was going to Amritsar from Kolkata and was stopped at Akbarganj after the police got information regarding the bomb.
Circle officer of Tiloi Veenu Singh said the bomb was found in the bathroom of an AC coach (B-3) in the train. It was noticed by a passenger at 1.17 AM.
Some passengers informed the ticket examiner and coach attendant about the bomb and soon railway authorities called the bomb disposal squad, which checked all the compartments.
After the bomb was defused, the train left Akbarganj station for its onward journey, Additional Superintendent of Police (ASP) BC Dubey said.
The bomb has been sent for forensic examination and the matter is being investigated, the ASP said.
The letter, which was in Hindi warned, "Dujana ki sahadat ka badla ab Hindustan ko chukana padega - Indian Mujahideen" (India will have to face consequences of Dujana's death - Indian Mujahideen), police said.
The Indian Mujahideen is a terrorist group formed in 2010 by Abdul Subhan Qureshi. It has been declared a terrorist organisation and banned by the Union home ministry.
Dujana, who belonged to Pakistan, was Lashkar-e-Taiba's 'divisional commander' in South Kashmir.
He was killed in an encounter with security forces in Pulwama district of J-K on August 1.
Dujana was wanted for many attacks on security forces and political workers in south Kashmir.