Prime Minister Narendra Modi, also in a message, expressed his condolences to the families of those who died or were grievously injured.
The accident took place around 11.30 p.m. Tuesday after Krishak Express jumped a signal that brought it on the same track on which the Barauni Express was running.
In his message to Uttar Pradesh Governor Ram Naik, the president said: "I am deeply saddened to learn about the accident in which a number of persons have lost their lives and some were injured, when two passenger trains collided near Gorakhpur district of Uttar Pradesh."
"I am sure that the state government is providing all possible assistance to the bereaved families who have lost their near and dear ones, as well as medical aid to the injured."
"Kindly convey my heartfelt condolences to the family members of the deceased. I pray to the almighty to give them the strength and courage to bear this irreparable loss. I wish speedy recovery to the injured persons," the president said.