Upulvan

Upulvan (, ; Sanskrit: Utpalvarna), also known as Vishnu ("Vishnu deviyo") is a guardian deity (Pali: Khettapala; Sanskrit: Kshetrapala) of Sri Lanka. Sri Lankan Buddhists believe him also as a protector of the Buddhism in the country. The name Upulvan depicts his body colour which means "blue water lily coloured". The cult of Upulvan started during the medieval period in Sri Lanka. According to the local lore and legend, Upulvan is the god whom the Buddha entrusted with the guardianship of Sri Lanka and Buddha Śāsana of the country.
Historical accounts and legends.
According to the Sri Lankan chronicles Dipavamsa and Mahavamsa, north Indian prince Vijaya and his seven hundred followers were blessed by god Upulvan upon their arrival to Sri Lanka in 543 BC. The second appearance of god Upulvan in literary sources occurs in the 7th and 8th centuries and again after a gap of several centuries his name reappears in 13th and 14th centuries as the god par excellence. Though god Upulvan is mentioned in Mahavamsa as the guardian deity of Sri Lanka, the first reference to the worship of Upulvan is dated to the 13th century.
Kotte era poem "Panditha Perakumba Siritha" describes a story of how god Upulvan transfigured a log of a kihiri tree and floated it to the sea beach of Devinuwara kingdom in Southern Sri Lanka. On the night prior to the incident, King Dappula I (661-664) who was the reigning monarch, had a dream about the arrival of this transfigured kihiri log. Accordingly, the king and his people rushed to the beach and recovered the kihiri log. They carved the god's figure out of the kihiri log, and brought it ceremonially for enshrinement. The poem further states that the wood of the said kihiri log was also used as a medicine for treating various diseases.
The "Paravi Sandesaya", written by Thotagamuwe Sri Rahula Thera in the 15th century mentions the name of the consort of god Upulvan as Sandavan Biso, and they have a son named Dhanu also called Janak.
In the medieval period local deities, namely Upulvan, Katharagama, Saman and Vibhisana came to be worshiped as protectors of the island. The 14th century inscription of King Buvanekabahu IV is the first inscription that refers to the guardian deities of Sri Lanka. Within the same century Nissanka Alagakkonara erected four shrines for the guardian deities when he was constructing the fortress of Kotte. God Upulvan seems to have been the most popular of these guardian gods and his main temple was located at Devinuwara (Dewundara) in Matara. "Dewundara Devala Sannasa" speaks of land dedicated to the temple by the ancient kings of Sri Lanka. A second temple for god Upulvan was erected by King Parakkramabahu IV at Aluthnuwara, Satara Korale in Kegalle District. Evidence reveals that land and other endowments were made to this temple up to the beginning of 17th century.
Identification with Vishnu.
At the end of the 15th century, god Upulvan was identified with god Vishnu of Hinduism, which could be attributed to the resemblance of the two deities and to the Hindu and Brahmin influence that prevailed during the times of Kotte Kingdom. Thereafter images of Upulvan as Vishnu were set besides the images of Buddha in Buddhist temples throughout the country. After the identity of god Upulvan was merged with god Vishnu, the use of name Upulvan slowly disappeared and the worship of Upulvan as Vishnu was spread throughout Sri Lanka. The deity was important for the Abisheka coronation rite.
Today it is commonly accepted both Upulvan and Vishnu as identical deities in Sri Lanka. But there exists different views about this identification and according to some historians and sources, the two deities are not identical. There are also sources that equate god Upulvan to the Vedic god Varuna, the protector and the lord of oceans, and in that capacity he is assumed as a protector of the island of Sri Lanka as well as Avalokiteśvara and Tara.
Major temples.
An ancient temple dedicated to god Upulvan was situated at Devinuwara in Matara, the southernmost area of the country. 
According to the recorded history, the Devinuwara multi-religious complex, the Buddhist temple and the Upulvan devale (shrine) was started by King Dappula I (Dappula-sen) in the 7th century AD. The origin of the Esala festival of Devinuwara goes back to the times of King Parakramabahu II who had reconstructed the dilapidated temples during his reign. Kings Parakramabahu VI, Vijayabahu VII and Bhuvanekabahu VII of Kotte made further grants to the temple. The sacred shrine is mentioned in the "Kokila Sandesaya" ("Message carried by Kokila bird") written in the 15th century with reference to the exploits of Sapumal Kumaraya. The temple complex was visited by Ibn Battuta in the 14th century and Zheng He in the 15th century. In 1587, a Portuguese army led by Thome de Sousa Arronches attacked the sacred city and destroyed the temples to distract king Rajasinha I's siege of Colombo. King Rajasinghe II managed to recapture Matara and re-built the shrine to god Vishnu, which is presently known as Uthpalawarna Sri Vishnu Devalaya.
Today Vishnu is venerated by a large number of devotees in Sri Lanka, and is specially revered as the custodian of the island. There are many temples and shrines which are dedicated to the god in many parts of Sri Lanka. Annual processions ("peraheras") are held to pay homage to the god in most of these temples. Other than the main temple and shrine in Devi Nuwara some of the famous Vishnu shrines and temples ("devalas & kovils") in Sri Lanka are located in Kandy, Vallipuram, Aluthgama (Kande Viharaya) and Dehiwala.
The chief lay custodian of each shrine is known as the Basnayaka Nilame.