Wilgam Raja Maha Viharaya is an ancient temple built originally built by King Devanam Piya Tissa during the 4th-century BC and received royal patronage under many other rulers of Sri Lanka including King Bathiya I, Agbo II, Vijayabahu I and the Great Parakramabahu. The temple has ruins of a stupa, image house, moonstones, balustrades and an amazing standing Buddha statue all of which resembles ruins of the ancient Anuradhapura.
During the Chola invasions in the 10th-11th century which ended the powerful Anuradhapura kingdom Sinhalese abandoned the capital and fled to the southern areas. While all the other temples underwent destruction Wilgam Raja Maha Viharaya managed to receive support from Rajaraja and his son Rajendra. A Tamil inscription suggests that Cholas renovated this temple and added new buildings and renamed it as Rajarajaperumpalli.
After Sinhalese king Vijayabahu I regained the throne in the 11th century he restored the temple again.
Even before Polonnaruwa the temple was supported by many Sinhalese kings. Another inscription made during the reign of King Bhatika Tissa in the 2nd-century mentions that the earnings from surrounding paddy fields were to be reserved for usage of the temple and the Buddhist monks.