The first citizens arrived to Castle Hill in the 13th century after the Mongolian invasion, seeking protection in the hills of Buda. The first royal castle was built around this time. The golden age of Castle Hill was in the 15th century, following the marriage of King Matthias Corvinus and Beatrix of Naples in 1476.
http://visitbudapest.travel/guide/budapest-attractions/buda-castle-hill/