This is the same narrative the vajrayanists use for other siddhas like virUpa. He rises in the ranks of a shaiva monastery only to defect by destroying the shiva-vigraha while taking refuge in the 3 jewels. He then restores the vigraha by placing lOkesvara on its forehead
There are shared motifs in this narrative, the one we originally posted and several others in the bauddha tantra-s which have a recurrent theme of the bauddha take over of shaiva-kShetra-s and pITha-s. There are other tales of virupa descrating H temples and replacing the central deity with a heruka while placing H deities in the AvaraNa. One may think it as formulaic and recycled. But we hold that it preserved a kernel of historical truth even if superimposed on different historical figures. There is the well known example of the li~Nga descrated by the bauddha-s by inscribing a dhAraNI on it in Soro village in Orissa.