Before dawn on May 6, 2016, a white police officer found himself face-to-face with a young black man holding a silver pistol. The officer could have fired a shot, but he didn’t.

That officer, Stephen Mader, now 26, was dismissed weeks later by the Weirton, W.Va., police department. Now he is suing the city, arguing that his show of restraint cost him his job.

According to the complaint filed on Wednesday by the American Civil Liberties Union of West Virginia on Mr. Mader’s behalf, the officer was responding to a domestic-disturbance call when he found Ronald Williams Jr. brandishing a pistol.

Mr. Mader concluded, according to the complaint, that Mr. Williams was despondent but not aggressive, and appeared to be trying to commit “suicide by cop.” He repeatedly said to Mr. Mader: “Just shoot me.”