Invasions by Norsemen that began in the late 8th century were finally ended when King Brian BORU defeated the Danes in 1014 .