In 776, Ma grew deathly ill, and he made Duan acting military governor before dying. With the soldiers gathering to mourn Ma, Duan was apprehensive that some soldiers would use this opportunity to mutiny. He therefore took careful precautions while arranging Ma's mourning, ordering that Ma's family, officers, soldiers, and commoners be segregated in their mourning and arresting anyone who disobeyed the orders. When he received reports that the officers Shi Tinggan (), Cui Zhen (), and Zhang Jinghua () were plotting mutiny and planning to rise at Ma's funeral, he defused the situation by sending Shi to Chang'an to serve in the imperial guards and sending Cui and Zhang out of the headquarters to other posts. He was thus able to preserve the peace at the circuit without killing anyone. In 777, Emperor Daizong made Duan the military governor. It was said that while Duan was strict, he was also gracious and governed simply. He did not gather wealth, and he did not have concubines. Except for official gatherings, he did not feast. In 778, when there was another Tufan incursion, Emperor Daizong sent Duan, along with Guo Ziyi and Zhu Ci, to defend against the incursion.