The tale of the dragons of Dinas Emrys actually begins with the tale of Lludd a Llefelys, as one of the plagues affecting the Island of Britain
The Tale of Lludd and Llefelys
The Welsh tale of Lludd and Llefelys is preserved in a collection of stories contained in two manuscripts, the English titles of which are the White Book of Rhydderch (written ca. 1300–25) and the Red Book of Hergest (ca. 1375–1425). The stories are thought to be much older, some dating back at least to the latter part of the eleventh century.
The tale is alluded to in The Lesser Reconciliation of Lludd, from the Book of Taliesin:
“Before the reconciliation of Lludd and Llevelys,
The possessor of the fair isle trembled" 
The earliest origins of this story are obscure and there appears to be evidence that The Tale of Lludd and Llefelys is independent of Geoffrey’s influence and based on an earlier tradition that existed before Geoffrey wrote his Historia; although Lludd rebuilding the city of London (Caer Lud) is found in the Historia (possibly based on the same tradition as Henry Huntingon), his brother Llefelys is not found in Geoffrey's work.
The story goes that while Lludd was king of the Island of Britain; it became infected with three supernatural plagues, or oppressions.
The Three Plagues of Lludd’s Reign:
• The first was a certain race that came, and was called the Coranians;  and so great was their knowledge, that there was no discourse upon the face of the Island, however low it might be spoken, but what, if the wind met it, it was known to them. And through this they could not be injured.
• The second plague was a shriek which came on every May-eve, over every hearth in the Island of Britain. And this went through people's hearts, and so seared them, that the men lost their hue and their strength, and the women their children, and the young men and the maidens lost their senses, and all the animals and trees and the earth and the waters, were left barren.
• The third plague was, that however much of provisions and food might be prepared in the king's courts, were there even so much as a year's provision of meat and drink, none of it could ever be found, except what was consumed in the first night. And two of these plagues, no one ever knew their cause, therefore was there better hope of being freed from the first than from the second and third. 
Lludd called upon his brother Llefelys, who was king of Northern France by marriage, for help in eradicating these three plagues. They met in the middle of the sea and spoke through a horn so as the Coraniaid could not hear them.
The first plague, the Coraniaid was finally eradicated insects bruised in water. Lludd had received the insects from his brother Llefelys in France who had told Lludd to keep some of them to breed with just in case a similar affliction might come to Britain in the future.
Llefelys said the second plague was due to a dragon in Lludd’s kingdom and another dragon of a foreign race is fighting with it. To overcome this plague, Llefelys told Lludd he would need to measure the length and breadth of the Island to find the centre, there dig a pit and place a cauldron filled with the finest mead, covered over by a satin cloth. They would appear as dragons fighting in the air and then tire and fall in the form of pigs into the cauldron, sink in to the mead, drink it and then fall asleep. Lludd would then need to bury them in the strongest part of the island.
When Lludd measured the island, Oxford was found to be the exact centre of the island of Britain. He captured the dragons as Llefelys had said and then wrapped up in the satin covering the cauldron. While they slept took them to the securest place he had which was in Snowdon, at a place then called Dinas Ffaraon, after that the spot was called Dinas Emrys, and from then on the May-eve shriek ceased.
To eradicate the third plague Lludd was only able to stop the recurring theft by confronting the intruder. To avoid falling asleep he kept dipping his head in a vessel of cold water by his side. Upon confronting the magician, a fierce encounter ensued in which Lludd overcame the magician. Thereupon, Lludd granted him mercy and made him his loyal vassal.
The Dragons of Emrys
The tale of the Dragons interned at Dinas Emrys seems to originate from belief in talismanic burial, as seen for example in the story from the Second Branch of the Mabinogi, Branwen Daughter of Llŷr which includes the story of the burial of Bran's head to protect the island. The burial of the two dragons keeps Britain safe from invasion, being one of the Three Fortunate Concealments, until they are unearthed by Vortigern, as one of the Three Unfortuate Disclosures.
The story is alluded to in the Triads:
37 R. Three Fortunate Concealments of the Island of Britain
The Head of Bran the Blessed, son of Llyr, which was concealed in the White Hill in London, with its face towards France. And as long as it was in the position in which it was put there, no Saxon Oppression would ever come to this Island; The second Fortunate Concealment: the Dragons in Dinas Emrys, which Lludd son of Beli concealed; And the third: the Bones of Gwerthefyr the Blessed, in the Chief Ports of this Island. And as long as they remained in that concealment, no Saxon Oppression would ever come to this Island.
And they were the Three Unfortunate Disclosures when these were disclosed And Gwrtheyrn the Thin disclosed the bones of Gwerthefyr the Blessed for the love of a woman: that was Ronnwen the pagan woman; And it was he who disclosed the Dragons; And Arthur disclosed the Head of Bran the Blessed from the White Hill, because it did not seem right to him that this Island should be defended by the strength of anyone, but by his own. 
It may allude to an even early mythological element of Britain’s pagan past, as we have seen previously Lludd’s daughter Creiddylad; Gwythyr the son of Greidawl and Gwynn the son of Nudd fight for her every first of May until doomsday. May-eve, Beltane is also probably named after the god Beli, father of Lludd. It is on Beltane that the Milesians came to Ireland, and so it was on Beltane that the Partholonians died.
In addition to Beltane, the Celtic fire festival heralding the onset of summer, May-eve is of course also Walpurgis Night, a traditional pagan festival, on April 30th. Walpurgisnacht is considered the "Enclosure of the Fallen" from Norse tradition and commemorates the time when Odin died. The night is said to be a time when the boundary between this world and the other world can be breached and spirits were said to walk among the living.
Christianised as St. Walpurga's day and set to May 1st, Saint Walpurga herself was a niece of Saint Boniface and, according to legend, a daughter of the Saxon prince St. Richard. It would seem that May-eve is traditionally a day when rulership is challenged and plagues appear.
Although Geoffrey of Monouth and the tale of Lludd and Llefelys, disagree on the fourth brother Llefelys, they concur in naming a third brother Nynyaw in Welsh (= Nennius in Latin), who plays no further part in the story.
The tale of the dragons concealed at Dinas Emrys is very significant in the early mythology of Britain. These are, no doubt, the same dragons which appear in 9th Century story of Ambrosius and Vortigern, attributed to a cleric named Nennius, c.800 CE, in the Historia Brittonum, from the Harlian 3859 manuscript.
The Tale of Lludd and Llefelys, albeit it in a bridged form, was included in later Welsh redactions of Geoffrey’s Historia, probably to account for how the dragons became buried in Dinas Emrys. Geoffrey names the boy Emrys as Merlin and hence the confusion of the two Merlins commences – but that’s another story!
Ambrosius becomes Emrys in Welsh, Dinas Emrys near Beddgelert in Snowdonia traditionally being his stronghold; he was referred to by Gildas as the Last of the Romans; Nennius hints to the possibility of civil war when he alludes to the Battle of Wallop between Ambrosius and Vortigern. From Nennius the concept of the red dragon as representing the Britons (this still represented on the flag of Wales today) in their struggle against the Anglo-Saxons is generally accepted. However, the white dragon may not be referring to Germanic invaders at all but the dragons could be representations of the two factions of Ambrosius and Vortigern.
According to the story Vortigern was advised by his wise men to retire to the remote boundaries of his kingdom and build a citadel, but three times the building collapsed, he was advised to: “find a child born without a father, put him to death, and sprinkle with his blood the ground on which the citadel is to be build,”
Hence, they found the boy Emrys who was not born of a mortal father and he was brought before Vortigern:
"there is," said he, "a pool;" they examined, and found it so: continuing his questions, "What is in the vases?" they were silent: "there is a tent in them," said the boy; "separate them, and you shall find it so;" this being done by the king's command, there was found in them a folded tent. The boy, going on with his questions, asked the wise men what was in it? But they not knowing what to reply, "There are," said he, "two serpents, one white and the other red; unfold the tent;" they obeyed, and two sleeping serpents were discovered; "consider attentively," said the boy, "what they are doing." The serpents began to struggle with each other; and the white one, raising himself up, threw down the other into the middle of the tent, and sometimes drove him to the edge of it; and this was repeated thrice. At length the red one, apparently the weaker of the two, recovering his strength, expelled the white one from the tent; and the latter being pursued through the pool by the red one, disappeared. Then the boy, asking the wise men what was signified by third wonderful omen, and they expressing their ignorance, he said to the king, "I will now unfold to you the meaning of this mystery. The pool is the emblem of this world, and the tent that of your kingdom: the two serpents are two dragons; the red serpent is your dragon, but the white serpent is the dragon of the people who occupy several provinces and districts of Britain, even almost from sea to sea: at length, however, our people shall rise and drive away the Saxon race from beyond the sea, whence they originally came; but do you depart from this place, where you are not permitted to erect a citadel” 
The Ancient Tripartite
French scholar George Dumezil theorises that the meaning of the story is based on a tripartite ideology from Indo-European society; sovereignty, force and fruitfulness. 
The three elements of the Welsh story Lludd & Lleuelys echo the features of the story of Naudu and Lug, the primary source being The Second Battle of Mag Tuired:
Nuada, The King of the Tuatha De Danann has lost his arm in battle against the champion of the Fir Bolg. He is given a prosthetic silver arm and is from then on known as Nuada Airgetlam (silver hand-arm). The new King of the Tuatha De Danann, Bres, is part Formonian and tyrannises his people, their leading warriors are reduced to demeaning chores and the poets are not wanted at the King’s court. The reign of Bres is characterised by the three functions; the sovereign has become a tyrant, the leading warriors have lost their might, and fertility is contravened by yielding crops as tribute. Enter Lugh who leads the Tuatha De Danann to victory against the Formonians.
In Lludd and Lleuelys the realm of the King has been weakened in each of the three elements:
The Coraniaid have effectively tyrannised the people with their magical powers of hearing, The May eve scream has reduced the strength of the warriors, The food not eaten on the first night of the feast in the king’s court, a year’s provision, disappears.
As we have seen Lludd appears to be synonymous with Lludd Lawereint, who is synonymous with Nuada Airgetlam, therefore both versions of the tale, Welsh Lludd and Lleuelys and the Irish Second Battle of Mag Tuired relate to a Celtic myth in which the god Nodons has lost his arm in battle and is besieged by three plagues. The three elements and consequently the kingdom are restored by the god Lugus (Irish = Lug, Welsh =Lleu). 
1 Skene in his Notes to the Four Ancient Books of Wales states that this is a curious poem giving an account of an early colonisation of Britain and suggests that this poem refers not to the Coraniaid of Cryfranc of Lludd and Llefelys, but the Romans. However, the word for Romans would be Caesarians, which is quite different and they are not listed in Triad 36 Three Oppressions that came to this island.
2 Coraniaid, variously spelt, probably related to the Welsh word corach translated as ‘dwarf’ and it is generally accepted that they are fairy people, the Tylwyth Teg, invading the island, as do the fairy races of Ireland, although the Triad says they came from Arabia
3 Cyfranc Lludd a Llefelys, Translated by Lady Charlotte Guest
4 Rachel Bromwich, (2006). Trioedd Ynys Prydein: The Triads of the Island of Britain.
5 Historia Brittonum, Attributed to Nennius, ca. 800 CE, Harlian 3859, Translation from Six Old English Chronicles by: J.A. Giles.
6 George Dumezil discusses the tale and shows that the three plagues that menace human society are an archaic formulation in Mythe et Epopee I, 1968, pp.613-623, - referred to in The Mabinogi and Other Medieval Welsh Tales by Patrick K Ford, pp. 111-112.
7 Celtic Culture, A Historical Encyclopedia By John T. Koch, 2006, pp 1164 – 1166.
Koch states that the name Llefelys appears to be a compound, the first element is the same as seen in the simplex name of the important pan-Celtic supernatural figure, Welsh Lleu, Old Irish Lugh, Celtiberian and Gaulish Lugus. Lleuelis the usual spelling in White Book and Red Book texts of the Cyfranc modernised as Llefelys. Patrick Ford writes this as modern Welsh Lleuelys, emphasing the connection with Lleu the central figure of the Math mab Mathonwy and counterpart of Lug.
* * *