It is a fiction based on the real character of Judge Dee (Ti Jen-chieh or Di Renjie - chin: 狄仁傑), a magistrate and statesman of the Tang court, who lived roughly 630–700.
However, van Gulik's novel is set not in the Tang, but in the Ming dynasty (1368–1644), with society and customs depicted in the book reflecting this period.