Wales was divided into a number of separate kingdoms, the largest of these being Gwynedd in northwest Wales and Powys in east Wales. Gwynedd was the most powerful of these kingdoms in the 6th century and 7th century, under rulers such as Maelgwn Gwynedd (died 547) and Cadwallon ap Cadfan (died 634/5), who in alliance with Penda of Mercia was able to lead his armies as far as Northumbria in 633, defeat the local ruler Edwin and control it for approximately one year. When Cadwallon was killed in battle by Oswald of Northumbria, his successor Cadafael ap Cynfeddw also allied himself with Penda against Northumbria, but thereafter Gwynedd, like the other Welsh kingdoms, was mainly engaged in defensive warfare against the growing power of Mercia.