Shankar Dayal Sharma, 81, an ally of India's foremost political dynasty who served as his country's president from 1992 to 1997, died Dec. 26 at a hospital here where he was being treated for heart and lung ailments.

Upon learning of Dr. Sharma's death, India's current president, K.R. Narayanan, issued a statement saying, "The passing away of my illustrious predecessor . . . is an irreplaceable loss for the nation."

The presidency of India is largely ceremonial. But when no single party commands a parliamentary majority, the president has discretion in deciding who should lead the next government. He also is formally commander in chief of the armed forces.

As president, Dr. Sharma earned a reputation for being scrupulously impartial. In 1996, he installed India's current prime minister, Atal Bihari Vajpayee, for his first term in office. Dr. Sharma was a sentimental public leader who sometimes broke down in Parliament before unruly lawmakers. He once said he believed in retaliating by shaming offenders with acts of kindness.

Before he took over public office, he had been associated for decades with the Congress party now led by Sonia Gandhi. He was considered close to the Nehru-Gandhi family that has given India three prime ministers, and worked closely with India's first prime minister, Jawaharlal Nehru.

Earlier, Dr. Sharma went to jail during the Indian freedom movement against British colonial rule. He studied law, receiving his doctorate from Cambridge University in England. He taught law for a time at Cambridge and also had been a visiting fellow at Harvard University's law school.

Survivors include his wife and two children.