Ziying (died January 206 BC) was the third and last ruler of the Qin dynasty. He ruled over a fragmented Qin Empire for 46 days from mid-October to early December in 207 BC. He is referred to in some sources with the posthumous name Emperor Shang of Qin (秦殤帝), despite Qin abolishing the practice of posthumous names. (In Chinese tradition, even someone who never held a ruling title while alive might be given the posthumous title "emperor" after his death.)
There is no firm consensus on what Ziying's relationship to the Qin royal family really is. He is mentioned in historical records as the son of Fusu, the eldest son of Qin Shi Huang. However, historian Professor Wang Liqun suggested that he was probably one of Qin Shi Huang's brothers. While Records of the Grand Historian does not specify Ziying's age, it implies that he had at least two sons, whom he consulted. According to Prof Wang's analysis, the maximum possible age of Qin Ershi when Ziying assassinated Zhao Gao was 19. Therefore, his sons would have probably been around the ages of 1–2, and hence it was not possible for him to consult them. It seems more likely that Ziying was an uncle of Qin Er Shi (and hence a brother of Qin Shi Huang) instead of Fusu's son. Some historians, including Li Kaiyuan and Ma Feibai, have also suggested that Ziying might be a son of Chengjiao, Qin Shi Huang's younger half-brother.
After Qin Er Shi's death, Zhao Gao chose Ziying to be successor, and changed the ruling title "emperor" back to "king" because the Qin Dynasty at that time was as weak as the former Qin State, which no longer ruled the whole of China, but held onto only Guanzhong.
Ziying was the only person within the Qin imperial court to defend and try to persuade Qin Er Shi against the wrongful executions of Meng Tian and Meng Yi. He lured Zhao Gao, the regent who assassinated Qin Er Shi, into a trap and killed him. Ziying later surrendered to Liu Bang, the leader of the first group of rebel forces to occupy Xianyang, the Qin capital. He was eventually killed along with his male family members by another rebel leader, Xiang Yu.
Ziying sometimes appears as a door god in Chinese and Taoist temples, usually paired with his successor, Emperor Yi of Chu.