(Adds detail from Singh funeral)
By Ashok Pahalwan
JAMMU, India, May 3 (Reuters) - A Pakistani prisoner was badly beaten in an Indian jail on Friday in apparent revenge for a fatal attack on an Indian jailed for spying in Pakistan whose death has led to an outpouring of anger and strained ties between the neighbours.
Sanaullah Haq was being treated for severe head injuries in hospital in the northern Indian state of Jammu and Kashmir, which borders Pakistan and has seen serious territorial disputes between the nuclear-powered nations.
"He was rushed to Jammu Medical College Hospital in critical condition as he had suffered severe head injury in the attack. We are making arrangements for critical care ambulance to shift him to Chandigarh or New Delhi for treatment," said Rajni Sehgal, superintendent of the Kotbawal jail where the attack happened.
The assault came a day after the death of Sarabjit Singh, convicted of spying and bomb blasts in Pakistan. He was hospitalized last week after two inmates attacked him in jail in the eastern Pakistani city of Lahore.
India's government and his family maintain he was an innocent farmer and he is considered a martyr by many in India.
Thousands gathered in Singh's home town near the border in the state of Punjab, which was divided when India and Pakistan were partitioned at the end of British rule in 1947.
Wrapped in an Indian flag, his coffin was carried through the streets before his cremation on Friday. Some shouted "Death to Pakistan". Police played the Last Post and gave a 21-gun salute at a state funeral organized by the Punjab government.
Crowded on rooftops and balconies in the summer heat, people watched the preparations amid heavy security deployed for dignitaries like Rahul Gandhi, scion of the Nehru-Gandhi dynasty, who attended the service.
Protesters took to the streets in several cities for a second day. India has accused Pakistan of not doing enough to protect Singh.
Several Indian states beefed up security in their jails. Many states already keep Pakistani prisoners segregated from their Indian counterparts.
Pakistan said the assault on Haq was "condemnable" and called on India to punish the attacker. India said it regretted the incident and promised consular access to Haq once his condition had stabilized.
India and Pakistan have fought three wars since 1947, although they began a peace process in 2004. They remain deeply suspicious of each other.
The latest flare-up follows an outbreak of violence in Kashmir in January, where two Pakistani and two Indian soldiers were killed.
Despite the recent strains, relations have improved after nose-diving in 2008 when gunmen killed 166 people in Mumbai in a three-day rampage that India blamed on a Pakistani militant group. Last year, India hanged Pakistani citizen Ajmal Kasab, who was convicted of taking part in that attack. (Additional reporting by Fayaz Bukhari and Katherine Houreld; Writing by Annie Banerji; Editing by Frank Jack Daniel and Nick Macfie)