What is the historical origin of Vajrapani? I've always found the imagery of Vajrapani (a wrathful Bodhisattva) very evocative. I'm reading a little bit about him and how his form is to do with energy and power in service of the Dharma so he is of course a positive figure. 



But I'm just wondering if anyone knows about the history of this figure and wrathful deities like him. Is he from the Tibetan culture and does he predate Buddhism coming into that country. Also is he a deity that perhaps had negative connotations (a demon perhaps) that Buddhism has co-opted?
Longchen Rabjam's Precious Treasury of Philosophical Systems (tr. Richard Barron) says:


  Traditionally, Manjushri is renowned for having compiled the tantras of enlightened form, Avalokiteshvara the tantras of enlightened speech, and Vajrapani the tantras of enlightened mind, qualities, and activity.


A footnote fills this out:


  In the sutra teachings, ''the lords of the three families" -- Manjushri, Avalokiteshvara, and Vajrapani -- are among the eight great bodhisattvas in the retinue of every nirmanakaya buddha such as Shakyamuni. In the ... context ... of the Vajrayana teachings, they are emanations who are not separate from the expounder of the tantras, whether Buddha Shakyamuni or the primordial buddha (usually referred to as Samantabhadra or Vajradhara, who expounded tantras considered to predate the historical Buddha). In the tantras, these emanations are part of the naturally manifest retinue that appears in the sambhogakaya realm of Akanishtha. In the sutras, these bodhisattvas are peaceful manifestations; in the Vajrayana, the emanations may appear in either peaceful or wrathful forms.


So, no negative connotations I'd say! I know Vajrapani appeared in Sanskrit first because he's mentioned in Ch. 10 of 'Way of the Bodhisattvas,' by the 8th century Indian buddhist monk Shantideva. Wiki mentions the earlier sutra that may have been Shantideva's reference (see link in comment).