Shara Karapetian, 23, had been so upset by the condition of his grandmother, Lucy Karapetian, that he barricaded himself in the hospital room where she was being treated for heart disease and kidney ailments.
The court was told how he tried to disconnect life-support machinery and tubes carrying vital drugs to the 84-year-old patient's heart.
But staff at New Ealing Hospital in west London burst in and saved her. Mrs Karapetian eventually recovered from her illness and was discharged from hospital.
Karapetian, of Ealing, west London, an engineering graduate now studying at Imperial College, was given an 18-month sentence, suspended for two years, after he was convicted of attempted murder.
The incident happened on 1 April during a family visit. Karapetian's uncle, Armen, had a disagreement with a nurse and as they were arguing Karapetian, who is receiving treatment for depression, slipped into his grandmother's room and used a table to barricade the door.
Simon Mayo, for the prosecution, said: "He then proceeded to switch off some of the life-support machines, which inevitably caused alarms to sound.
"The nursing staff rushed to the room, but they couldn't gain entry. During that time, this defendant attempted to disconnect the tubes administering drugs. It appears he was unsuccessful, and he then took a pair of scissors that were in the room and cut the central line."
Karapetian told detectives: "I was just sick of the whole situation and just how I felt everyone was torturing my gran for their own selfish reasons. I thought my grandfather was refusing to let her die a peaceful and natural death."
Noel Lucas, for Karapetian, said he was devoted to his grandmother, and was trying to do what he thought best. Karapetian's medication for depression had given him a "dislocated perception" of reality at the time of the incident.
Mr Lucas added: "It is wholly exceptional, and is brought about by a desire to do good as opposed to any harm. In his own mind it was not regarded as an attempt to kill. He thought he was doing something of benefit to her."
The judge, the Common Serjeant of London, Neil Denison QC, said it was a most "exceptional case".
He told Karapetian: "You are a young man with a positive good character. But on 1 April you suddenly decided to try to end the life of your old and ailing grandmother, to whom you were plainly devoted.
"Your motive was to ease her passing, so this was in a sense a bizarre form of an attempt at a mercy killing. Happily you did not succeed and, as a result of skilled medical treatment, the old lady has recovered."Reuse content