He was an Elf, the son of Eöl the Dark Elf and Aredhel daughter of Fingolfin. He lived in the First Age of Middle-earth, and was a lord of Gondolin. His name means "sharp glance" in Tolkien's constructed language Sindarin.
According to The Silmarillion, Maeglin's mother, Aredhel, grew weary of Gondolin and wished to visit the sons of Fëanor; she then wandered through Beleriand. In the woods of Nan Elmoth she was lured by the "Dark Elf" Eöl, and was married to him -- "a matter in which she was not wholly unwilling", eventually giving birth to Maeglin.
At birth, Aredhel gave Maeglin the name Lómion, meaning "Son of the Twilight" in Sindarin. Eöl gave his child the name Maeglin when he was 12. Aredhel left Eöl, and took her son (who stole his father's sword, Anguirel) with her, returning to Gondolin. Eöl followed her, and in judgment before Turgon, the king of Gondolin, he attempted to kill Maeglin with a poisoned javelin, but hit Aredhel instead. Aredhel begged her brother to forgive Eöl, as she still loved him despite not wanting to live with him. She in fact succeeded in this until she grew sick and died because the spear was poisoned. Eöl was cast down to his death from the city walls by an enraged Turgon.
Maeglin was now an orphan, but Turgon took him in. He became an elven-prince held in high esteem, even leading his own House of the Mole. He found rich lodes of metals in the Echoriath surrounding the city, and forged weapons of steel stronger than had been seen before. His mine in the Echoriath was named Anghabar, or "Iron-Mine". In the Nírnaeth Arnoediad, Maeglin refused to remain behind as regent, and went forth to battle with Turgon. The seventh and final gate of Gondolin, the Great Gate of Steel, was Maeglin's creation.
When Tuor came, carrying Ulmo's warning of the danger to Gondolin, Maeglin sat at Turgon's side and argued against Tuor. Tuor's marriage with Idril further incensed Maeglin, who rebelled against Turgon and Tuor. Later, seeking after metals, Maeglin defied Turgon's order to stay within the mountains, and was captured by Orcs and brought to Angband. It was only after Morgoth promised him both Gondolin and Idril in return for the location of the hidden city, that he agreed to reveal the location of Gondolin. When Morgoth's armies attacked and overran the city, Maeglin fought with Tuor on the walls, and Tuor threw him to his death. This was the way his father had been executed before for the killing of Aredhel, and it was also the curse that Eöl had placed on Maeglin at this event - to suffer the same fate as he.
He is the only Elf to ever willingly and knowingly become a servant of Morgoth. His treason is unique, as even the kinslaying Sons of Fëanor sought glory for their house, and maintained a hatred for the Dark Lord.