Elgin is a town and formerly a Royal Burgh in Moray, Scotland. It is the administrative and commercial centre for Moray. The town originated to the south of the River Lossie on the higher ground above the floodplain where the town of Birnie is. There, the church of Birnie Kirk was built in 1140 and serves the community to this day. Elgin is first documented in the Cartulary of Moray in 1190 AD. It was created a royal burgh in the 12th century by King David I of Scotland, and by that time had a castle on top of the present-day Lady Hill to the west of the town. The origin of the name Elgin is likely to be Celtic. It may derive from 'Aille' literally signifying beauty, but in topography a beautiful place or valley. Another possibility is 'ealg', meaning both 'Ireland' and 'worthy'. The termination 'gin' or 'in' are Celtic endings signifying little or diminutive forms, hence Elgin could mean beautiful place, worthy place or little Ireland.