Muiredach mac Brain (died 818) was a King of Leinster of the UàMuiredaig sept of the UàDúnlainge branch of the Laigin. This sept had their royal seat at Maistiu (Mullaghmast) in South Kildare. He was the son of Bran Ardchenn mac Muiredaig (died 795), a previous king. He ruled from 805 to 806 and again from 808 to 818.
Though not listed in the king list in the Book of Leinster, he is mentioned in the Irish annals. He is given the title (one of two kings) at his death in 818 (Annals of Ulster) and ruled in conjunction with Muiredach mac Ruadrach (died 829) of the UàFáeláin sept.
In 795 his father, Bran, had been assassinated by his successor FÃÂnsnechta Cethardec mac Cellaig (died 808) of the UàDúnchada sept as a direct challenge to the high-king. In 805 FÃÂnsnechta was deposed by the high king ÃÂed Oirdnide (died 819) of the Cenél nEógain who installed Muiredach mac Brain and Muiredach mac Ruadrach as kings. Finsnechta took refuge with Muirgius mac Tommaltaig (died 815), the King of Connacht who then aided him in recovering his throne in 806.
Upon the death of Finsnechta, Muiredach mac Brain and Muiredach mac Ruadrach were returned to rule. In 814 a battle is recorded between the UÃÂ Cheinnselaig of south Leinster and the sons of Bran. The battle was won by the sons of Bran, probably Muiredach and his brother Cellach mac Brain (died 834). Upon the death of Muiredach mac Brain, Muiredach mac Ruadrach became sole ruler.
Muiredach's sons, Tuathal mac Muiredaig (died 854) and Dúnlaing mac Muiredaig (died 869) were also kings of Leinster. Another son Artúr mac Muiredaig (died 847) was king of western Liffey, Iarthair Liffey.