Ecgfrith was born in 645 to king Oswiu and Eanflæd his queen. At about the age of 10 Ecgfrith was held as a hostage at the court of Queen Cynewise after her husband king Penda of Mercia invaded Northumbria in 655. Penda was eventually defeated and killed in the Battle of the Winwaed by Oswiu a victory which greatly enhanced Northumbrian power. To secure his hegemony over other English kingdoms Oswiu arranged a marriage between Ecgfrith and Æthelthryth, a daughter of Anna of East Anglia, he was possibly as young as 15 at the time. Ecgfrith was then made king of Deira in 664 after his half-brother Alhfrith had rebelled against Oswiu earlier that year.