A modern young man travels back to the early Ming Dynasty, becoming a county magistrate. Relying on knowledge, he gains the emperor's appreciation. As court disputes emerge, he introduces reforms and helps the new monarch. When foreign enemies invade, he leads troops to defend the border. After peace, he resigns and wanders with his lover.