The town is first mentioned as Medilica in 831 in a donation of Louis the German; the name is from a Slavic word for 'border.'[3] The area around Melk was given to Leopold I, Margrave of Austria, in the year 976 to serve as a buffer between the Magyars to east and Bavaria to the west. In 996 mention was first made of an area known as Ostarrîchi, which is the origin of the word Österreich (German for Austria).