It is generally accepted by both adherents of Dorje Shugden and opponents of the practice that Dorje Shugden appeared in his current form as the reincarnation of a Buddhist Teacher in the Gelugpa Tradition named Ngatrul (Tulku) Dragpa Gyaltsen. Dragpa Gyaltsen was a highly-regarded teacher at the same time as the Fifth Dalai Lama (17th century CE).
...
It is generally accepted by both adherents of Dorje Shugden and opponents of the practice that the appearance of Shugden in his current form is traced back at the time of the 5th Dalai Lama. According to Mills, he is "Supposedly the spirit of a murdered Gelugpa lama who had opposed the Fifth Dalai Lama both in debate and in politics, Shugden is said to have laid waste to Central Tibet until, according to one account, his power forced the Tibetan Government of the Fifth Dalai Lama to seek reconciliation, and accept him as one of the protector deities (Tib. choskyong) of the Gelukpa order." According to anthropologist Mumford, who studied the practice of Dorje Shugden among Nyingma adherents in Nepal, the 5th Dalai Lama tried to subjugate Tulku Dragpa Gyaltsen as a spirit through various rituals, which were not successful.