Modred is first mentioned in the Welsh tradition. Here his name is Medraut and they tell about the fight at Camlan. Mordred and Arthur would have died there. However they don't say that Mordred was Arthur's traitorous deputy, in league with the barbarians. It doesn't even say that they fought on opposite sides1.

The first time Mordred appears as an enemy of Arthur and as a traitor, is in Geoffrey Monmouth's History of Kings of Britton. Geoffrey changes the Welsh name of Medraut to the Cornish Mordred. He wants to avoid confusion with the French word merde. In Monmouth his story, Mordred is the nephew of Arthur. Once Arthur goes to the Roman empire to fight with the Romans, Mordred makes himself king and marries Guinevere. Mordred falsely spreads the news that Arthur is dead. When Arthur goes back to his homeland, Mordred awaits him with an army. They fight against each other and the battle ends when Arthur en Mordred fight one to one. Mordred dies and Arthur ends up mortally wounded2.

The story indicates that Mordred was British and previously a follower of Arthur. No one can tell by the story of Geoffrey why Mordred turned against Arthur2.
The Welsh sources Geoffrey must have used, didn't mention Arthur fighting against Mordred. This must be something Geoffrey added himself.

There is another triad which connects Mordred with Guinevere for the first time: Mordred is said to have raided Arthur's Court in Cornwall in one of the Three Unrestrained Ravagings, dragged Guinevere from her chair and struck her. But it is not clear if Mordred fought against Arthur at Camlann because of that; all that all that is told, is that a blow ‘struck upon Guinevere' by her sister Gwenhyfach resulted in ‘the Action of the Battle of Camlann'3.

John of Fordun, a Scottish chronicler even said that Mordred was the rightful heir to the throne of Britain. He says that Arthur wasn't an illegitimate child and in his eyes Mordred was. There are no other sources which lay the foundations of this story1.

In Geoffrey's Life of Merlin , Mordred is first mentioned as Arthurs son. It doesn't have much impact in the story, but the Vulgate Cycle definitely used this source to claim that Mordred was Arthurs incestuous son1.

According to some Mordred was the one to reveal the affair of Guinevere and Lancelot1.

There are roughly said tow candidates to be the historical source of Mordred; Medraus ap Llew ap Cynfarch, the nephew of Urien of Rheged and Medraut ap Cawrdaf ap Caradog Freigfras.
The first mentioned died in 580 and would have lived to late to have fought Arthur at the Battle of Camlan. However, it is possible Geoffrey used him as one of his historical characters on which he based Mordred.

The more likely candidate is Medraut ap Cawrdaf. Cawrdaf was the father of Medraut and was a chief officers of the island of Britain. It looks like he was the prime minister and chief adviser to King Arthur. The Welsh Triads also record that Cawrdaf's father, Caradog Freichfas, was Arthur's Chief Elder at his court of Gelliwig in Crenyw. This would mean that Medraut was member of a very powerful family. This may be the reason why Arthur appointed him as his regent2.

Another historical source of Mordred might have been Roger Mortimer. There is not much known about him, only that he has some several things in common with Mordred. They are both traitors to the throne and take over the throne when they can3.