In Warhammer 40K Ahriman is the Cheif Librarian of the Thousand Sons Legion of Space Marines. His greatest mark on the chapter was the spell, known as Ahriman's Rubric, that caused the Thousand Sons warriors to be the lifeless automata that they are today.
Ahriman is the greatest sorcerer in the chapter other than the Primarch Magnus. Before the Horus Heresey, Ahriman and Magnus shared a dangerous obsession with arcane mysteries and artifacts. This led Ahriman to come into possession of the Book of Magnus, an artiact of incredible sorcerous power. It is thought that this book is the source of the knowledge that allowed him to cast his Rubric. Magnus was none to pleased with Ahriman about his Rubric and was ready to eradicate him and all of his followers when their patron - Tzeentch himself - intervened. As is always the case, why the Lord of Change does what it does is never clear, but the effect was that instead of being killed, Ahriman was banished from the Planet of Sorcerers of the Thousand Sons and condemned to wander the Eye of Terror to try to gain understanding of Tzeentch.
Ahriman does not recognize Chaos as his master, he does not recognize anyone as his master. He is a scourge, taking orders from no one and acting only when it furthers his own plans. Over the millenia, Ahriman has made a career of raiding any place of knowledge that may contain artifacts, data, sometimes even people that he believes can grant him mastery of the way of the sorcerer.
Most often, Ahriman doesn't bother to take direct action. He fosters cults on many worlds at once. He grants the cult magi with sorcerous power until they accomplish whatever goal he gave them to do at which point he eliminates them.
Recently, it has been rumored that Ahriman has turned his attention to the Eldar. He is determined that the knowledge he seeks is contained in the vast collection of knowledge and arcana often referred to as the Black Library.
Rubric of Ahriman:
The Rubric of Ahriman is one of the most powerful spells ever cast. When the Traitor Legions turned against the Emperor, many of them were given "gifts" from their Dark Masters. Ahriman was disgusted by the mutations befalling the Thousand Sons and decided to stop it. He gathered a cabal of other Sorcerers who at first resisted his ideas but eventually they saw he was correct and together they set out to stop this. Using the Book of Magnus they created the Rubric which accomplished the desired effect, but with terrible results. The Rubric released a torrent of magical energy that ravaged the Thousand Sons' planet until it was ended by Magnus himself. In the end, everyone with Sorcerous power was either destroyed or had their power greatly augmented. Those without any of this power had their armor sealed shut, destroying the brother within and trapping their soul in their armor for eternity. Though this had a terrible effect on the Chapter, Ahriman was satisfied - he had stopped the mutation of the Chapter. It is because of this, Magnus would have killed Ahriman if not for the intervention of Tzeentch, and that Ahriman was banished from the world of Sorcerers.
In game terms, Ahriman is a very useful unique character to bring along. His attacks can be devastating and he is very tough to take out. Definitly a key piece in any Tzeentchian army, and with some Khorne Berzerkers no force can stand against him for long.
NOTE: information from Codex: Chaos 3'rd edition, the Games Workshop website, my memory, and many played games.