In Chinese mythology and religion, King Yan () is the god of death and the ruler of Diyu, overseeing the "Ten Kings of Hell" in its capital of Youdu. He is also known as King Yanluo (), a transcription of the Sanskrit for "King Yama" (/, ). King Yan is the fifth judge in the court of underworld. In both ancient and modern times, Yan is portrayed as a large man with a scowling red face, bulging eyes, and a long beard. He wears traditional robes and a judge's cap or a crown which bears the Chinese character for "king" (). He typically appears on Chinese hell money in the position reserved for political figures on regular currency.

Journey to the West
King Yan featured in the classic Chinese novel Journey to the West. One day, Sun Wukong invited his friends, the six demon kings and the Bull Demon King, to dine at his cave, and they drank until they were all incapacitated. When Sun Wukong fell asleep, he dreamt that he saw Ox-Head and Horse-Face carrying a warrant to carry his soul away to the gates of Hell. Sun Wukong, getting angry, drew out his golden staff from behind his ear and beat Ox-Head and the Horse-Face with it. He then tore off the rope that bound him, cast off his handcuffs and went into the Court of Hell. He frightened Ox-Head and Horse-Face causing them to flee towards the court of King Yan. They reported the matter to the great chief while crying. 

When Sun Wukong met King Yan, he said 

King Yan replied, 

After this, Sun Wukong wiped his name from the Book of Life and Death, a collection of books containing the names of every mortal alive which had the ability to manipulate lifespan. Furthermore, he erased the name of every monkey he knew.

After the Jade Emperor received reports from King Yan and Four Seas Dragon Kings, the Jade Emperor ordered the Ten Yama Kings and the heavenly army to capture Sun Wukong. The Monkey King, now sentenced to death for extorting the Dragon Kings, then defied the attempt to collect his soul.

Variety of interpretations 

In the syncretic and non-dogmatic world of Chinese religious views, King Yan's interpretation can vary greatly from person to person. While some recognize him as a Buddhist deity, others regard him as a Daoist counterpart of Bodhisattva Kṣitigarbha. Generally seen as a stern deity, King Yan is also a righteous and fair Supreme Judge in underworld or skillful advocate of Dharma.

King Yan is not only the ruler but also the judge of the underworld and passes judgment on all the dead. He always appears in a male form, and his minions include a judge who holds in his hands a brush and a book listing every soul and the allotted death date for every life. Ox-Head and Horse-Face, the fearsome guardians of hell, bring the newly dead, one by one, before Yan for judgement. Men or women with merit will be rewarded good future lives or even revival in their previous life. Men or women who committed misdeeds will be sentenced to suffering or miserable future lives. In some versions, Yan divides Diyu into eight, ten, or eighteen courts each ruled by a Yan King, such as King Chujiang, who rules the court reserved for thieves and murderers.

The spirits of the dead, on being judged by Yan, are supposed to either pass through a term of enjoyment in a region midway between the earth and the heaven of the gods or to undergo their measure of punishment in the nether world. Neither location is permanent and after a time, they return to Earth in new bodies.

Yan was sometimes considered to be a position in the celestial hierarchy, rather than an individual. There were said to be cases in which an honest mortal was rewarded the post of Yan and served as the judge and ruler of the underworld. Some said common people like Bao Zheng, Fan Zhongyan, Zhang Binglin became the Yan at night or after death.  Once a King of Hell has served out his sentence in Hell, he is able to reincarnate on Earth again or leave the cycle entirely.

Relationship with Indian religion
Drawing from various Indian texts and local culture, the Chinese tradition proposes several versions concerning the number of hells and deities who are at their head. It seems that originally there were two competing versions: 136 hells (8 big ones each divided into 16 smaller ones) or 18 hells, each of them being led by a subordinate king of Yanluo Wang.

They were strongly challenged from the Tang dynasty by a new version influenced by Daoism, which adopted Yanluo Wang to make it the fifth of a set of ten kings ( , Guardian king-sorter of the ten chambers) each named at the head of a hell by the Jade Emperor. The other nine kings are: Qinguangwang (), Chujiangwang (), Songdiwang (), Wuguanwang (), Bianchengwang (), Taishanwang (), Pingdengwang () Dushiwang () Zhuanlunwang (), typically Taoist names. They compete with Heidi, another Taoist god of the world of the dead. Yanluo Wang remains nevertheless the most famous, and by far the most present in the iconography.

However, Yanluo Wang later disappears completely from the list, giving way to a historical figure, a magistrate appointed during his lifetime as judge of the dead by a superior deity. This magistrate is most often Bao Zheng, a famous judge who lived during the Song dynasty. Sometimes he is accompanied by three assistants named "Old Age", "Illness" and "Death".

Yama is also regarded as one of the Twenty Devas ( ) or the Twenty-Four Devas ( ), a group of protective Dharmapalas, in Chinese Buddhism.

References

Chinese gods
Japanese gods
Death gods
Underworld gods