During the early days of early days of formation, Buddhism didn’t have many deities to deal with. The Predominant deities of those times were Indra and Brahma. In the Tripitaka, all these deties are shown completely subservient to the Buddha. They are potrayed as waiting and attending upon the Buddha, and as receiving many teaching from the Buddha himself. At one instance, it is even said the Maha-Brahma himself had advised a Brahmin who had reached the heavenly Brahma-realm, to clear his doubts with the Buddha instead of him !
As Buddhism evolved over times, it had to face the new Puranic Brahmanism with the influence of the Vishnu, Shiva and other deities rising over time, compared to the other Vedic deities who were now often reduced to a tutelary status. Puranic Brahmanism was highly syncretic assimilating everything that came in its way. Even Buddha himself was assimilated to the Brahmanical Pantheon as one of the Avatar-s of Vishnu. At the same time, Buddhism had also attempted in assimilation of the Brahmanical Deities into its fold. However, this part is not that much widely known.
Buddhism in its Theravada version was more orthodox, and didn’t officially expand beyond the already assimilated Indra, Brahma and other early deities. [Though Sri Lankan Theravada assimilated Vishnu as a Kshetra Pāla – Protector of the Land, but that was outside the Theravada Canon]. However, Mahayana Buddhism was highly assimilative in nature. The framework of Mahayana easily enabled the direct import of deities into its fold. When Mahayana was faced with Shaivism and Vaishnavism, it also had played its part of trying to assimilate Shiva and Vishnu in Mahayana.
More specifically, we’ll deal only the Assimilation of Shiva as a deity into Buddhism. Shiva was initially considered as an Emanation of Avalokiteshvara. It was also believed that Shiva himself will attain Buddhatva (i.e Buddhahood) in the future as Bhasmeshvara Buddha.
We’ll see some Buddhist Sutras that directly reference to Shiva as a deity. (There are also Buddhist Tantras that deal with Shiva but thats for another day
Lotus Sutra i.e Saddharma Puṇḍarīka Sūtra is one of the earliest Mahayana Sutra that speaks of Shiva as an emanation of Avalokiteshvara. The 24th chapter of the Lotus Sutra, “The Chapter on the Universal Door [of Avalokiteshvara]” (Samanta-Mukha-Parivarta) deals with description of the various emanation of Avalokiteshvara in our Universe, the Sahā Lokadhātu .
In this Chapter, Bodhisattva Akshayamati proceeds to ask the Buddha on how Avalokiteshvara frequents this world, the various methods He teaches the Dharma and also his Skillful means (Upāyakauśalya) adopted by him to teach the Dharma to all sentient beings.
atha khalvakṣayamatirbodhisattvo mahāsattvo bhagavantametadavocat-kathaṁ bhagavan avalokiteśvaro bodhisattvo mahāsattvo’syāṁ sahāyāṁ lokadhātau pravicarati? kathaṁ sattvānāṁ dharmaṁ deśayati? kīdṛśaścāvalokiteśvarasya bodhisattvasya mahāsattvasyopāyakauśalyaviṣayaḥ?
Again the Bodhisattva Mahāsattva Akshayamati said to the Lord: How, O Lord, is it that the Bodhisattva Mahāsattva Avalokitesvara frequents this Saha-world? And how does he preach the Dharma? And which is the range of the skilfulness of the Bodhisattva Mahāsattva Avalokitesvara?
The Bhagavan replies as follows:
evamukte bhagavānakṣayamatiṁ bodhisattvaṁ mahāsattvametadavocat-santi kulaputra lokadhātavaḥ yeṣvavalokiteśvaro bodhisattvo mahāsattvo buddharūpeṇa sattvānāṁ dharmaṁ deśayati […] keṣāṁcit pratyekabuddharūpeṇa avalokiteśvaro bodhisattvo mahāsattvaḥ sattvānāṁ dharmaṁ deśayati| […] keṣāṁcid brahmarūpeṇāvalokiteśvaro bodhisattvo mahāsattvaḥ sattvānāṁ dharmaṁ deśayati […] maheśvaravaineyānāṁ sattvānāṁ maheśvararūpeṇa dharmaṁ deśayati […]
So asked, the Lord replied to the Bodhisattva Mahāsattva Akshayamati: There are [some] worlds, young man of good family, [where] the Bodhisattva Mahāsattva Avalokitesvara preaches the Dharma to creatures in the form of a Buddha […] To some [beings] he preaches the Dharma in the form of a Pratyekabuddha […] To some [beings] he preaches the Dharma in the shape of a Brahma […] [to those] who are to be converted by Mahesvara, he preaches assuming the form of Mahesvara. […]
The Buddha describes that Avalokiteshvara by his Skillful means takes numerous forms like that of a Pratyekabuddha, Shravaka, Brahma, Yaksha, Gandharva including Shiva to teach the Dharma to the Sentient Beings. It must be noted that Shiva is not specifically discussed here, he is just included as a passing reference among all other emanations of Avalokiteshvara. It can be considered that, at this time the Buddhists had begun to consider Shiva as an emanation of Avalokiteshvara.
Karandavyuha is one of the major Mahayana sutras that is devoted completely to Bodhisattva Avalokiteshvara. It attempts at assimilation of the all the Brahmanical deities at one go, by establishing Avalokiteshvara as the progenitor of those deities.
The Sutra starts with the Nidāna – Evam Mayā Shrutam [Thus, It was heard by me ] – The Buddha residing at Sharavasti, in the Garden of Anathapindaka along with a host of Bodhidhattvas and Bhikshus. The Deities of the heavenly realms are shown to attend the Buddha’s Sermon, headed by Vishnu and Shiva. Shiva himself is potrayed as attending the Buddha’s sermon. In the Fourth Chapter of the Sutra on the Creation of Moon and others [candrādyutpattirnāma caturthaṁ prakaraṇam ], the Buddha explains how Avalokiteshvara assumes the form of Srishtikarta Lokeshvara to emanate all the [Brahmanical] deities from His body
Specifically, Buddha says that Shiva was born from Avalokiteshvara’s forehead - lalāṭānmaheśvaraḥ.
[More here : Srishtikarta Lokeshvara ]
After emanation of Shiva from his Body, Avalokiteshvara tells Mahesvara that, during the kaliyuga, he will appear in a degenerate realm and will be called the primordial god (ādideva), the creator and author of the world. The beings in this realm at that time will be deprived of the path to awakening and the talk among those foolish common people will be: “It is said that space is his linga and the earth his pedestal. He is the ground of all and is called linga because all beings dissolve into him”. 
The Shaivaite Doctrine is directly rebuked here, those who worship Shiva as the Creator deity are criticized as “foolish common people” (pṛthagjana).
Moving further to the narrative end of the Sutra, Shiva appears before the Buddha, prostrated before him and asks for Vyakarana [Prediction of Buddha-hood]. He is directed by the Buddha to Avalokiteshvara. Maheshvara praises Avalokiteshvara and requests Vyakarana from him. On his request Avalokiteshvara bestows the prophecy for Buddhahood.
bhaviṣyasi tvaṁ kulaputra vivṛtāyāṁ lokadhātau bhasmeśvaro nāma tathāgato’rhan samyaksaṁbuddho vidyācaraṇasaṁpannaḥ sugato lokavidanuttaraḥ puruṣadamyasārathiḥ śāstā devānāṁ ca manuṣyāṇāṁ ca buddho bhagavān
Kulaputra ! In the future you will become in the World called Vivrita, a Tathagata named Bhasmeshvara, an Arhat, One who is perfect in knowledge and conduct, a Sugata, Knower of the Word, Unsurpassed-one, Tamer of Men, Teacher of the Gods & Men, Buddha and the Lord.
(Stotras of Shiva/Umadevi on Avalokiteshvara can be read here: Karandavyuha Stotras on Avlaokiteshvara )
The Tantra Text Sarva-Tathagata-Tattva-Sangraha also contains information of Shiva’s conversion as the future Bhasmeshvara Buddha, but with a different narrative. We’ll deal that along with the other Tantra references to Shiva.
Though the Shaivaite doctrine is criticized in the Beginning, ultimately at the end Shiva is accepted into Mahayana Buddhism as a future completely enlightened Buddha.
As Shiva was considered as a emanation of Avalokiteshvara, many of Shiva’s features were also attributed to Avalokiteshvara, again an attempt to subsume Shiva under Buddhism. Again, that requires a detailed study on its own. In fact, not specifically Shiva but the attributes of the dual deity Hari-Hara or Shankara-Narayana seems to have been overlaid on Avalokiteshvara. There will be some posts on the related topics as dicussed here, so do keep an eye on the Site :-P.