Edward I conquered Wales and when his fourth son and eventual successor, Edward, was born in Caernarvon castle, he named him Prince of Wales. This has been a common practice ever since among the kings of Britain. Today, the heir to the throne is Prince Charles, and he was invested as Prince of Wales in Caernarvon Castle in 1969.
But these princes had no right to the title, except the power of the king to bestow it. The last rightful Prince of Wales was Llywelyn ap Gruffudd in 1258.
When Llywelyn the Great died in 1240 his oldest two sons battled for the inheritance. The elder, Gruffudd [pronounced Griffith], was illegitimate, but despite Welsh law giving equal rights to illegitimate children, the other, Dafydd [pronounced Daveeth], was the one designated as heir. Dafydd died without an heir, and Gruffudd having already died, the leadership fell to Gruffydd's two older sons, Owain and Llywelyn.
Under the Treaty of Woodstock in 1247, they were made to accept the division of Gwynedd. Henry III took the east, and the west was divided between the brothers. Unhappy with this, the brothers fought each other, then Llywelyn imprisoned Owain and regained the whole of Gwynedd and parts of Powys and Deheubarth in a series of lightning campaigns. In 1258 he adopted the title Prince of Wales.
Henry III formally acknowledged Llywelyn's position in the Treaty of Montgomery in 1267. The historian David Walker says in his book Medieval Wales that the Treaty offered the most favourable terms ever extracted from the English crown. Llywelyn used the following decade to consolidate the great Welsh dynasties into a united country. Poets addressed him as 'the true king of Wales' (gwir frenin Cymru).
When Henry died in 1272 and was succeeded by his son Edward I, Llywelyn refused to attend the coronation or come to pay homage. There is no record of his reasons, but his continued refusal led to Edward invading Wales in 1277. The Treaty of Aberconwy deprived Llywelyn of all his lands except Gwynedd west of the Conwy River. His title as Prince of Wales meant very little.
Sadly, the peace didn't last. Llywelyn's younger brother Dafydd started a rebellion in 1282, and Llywelyn realised he had no choice but to join his brother against the king. They were initially successful, but Llywelyn was surprised by a small party of English soldiers who killed him without realising who he was. Later, when he was identified, his head was cut off and sent to Edward who had it displayed at the Tower of London.
His body was buried near were it fell, a place called Cefn y Bedd. As Llywelyn ap Iorwerth was named Llywelyn the Great, so his grandson Llywelyn ap Gruffudd was named Llywelyn the Last.