Hang 'Em High
(1968)

Jed Cooper (Clint Eastwood) is falsely accused of stealing cattle, and lynched by 9 cowboys. However, he survives and is rescued. When he recovers, the judge offers him a job as a US Marshall. He is given warrants to arrest the 9 men who lynched him, with strict instructions to bring them back for trial, not kill them. He finds one in a bar. Cooper tries to arrest him, but has to shoot in self defense when the man draws a gun. He catches another (Bruce Dern) rustling cattle with two teenage boys.

The three of them are hanged for murder and rustling, despite Cooper's attempts to have the boys spared. Cooper arrests a third man (Alan Hale, skipper from Gilligan's Island), who ends up shot by another sheriff trying to escape. A fourth man turns himself in, rather than be hunted down by Cooper. He is sentenced to 10 years in jail.

Three of the remaining five lynchers decide they have to kill Cooper. They break in and shoot him in his home. Again he survives, nursed back to health by Rachel. Rachel is a young widow, whose husband was murdered by two men. She inspects every wanted man brought in, hoping to find her husband's killers. When Cooper recovers he goes after these 3. They are holed up together in a house. Cooper kills two, and finds that Captain Wilson, the head of the lynch mob, has hanged himself rather than face Cooper.

Cooper wants to quit and marry Rachel. The judge does not want to lose his best marshall. Cooper will stay on if the judge releases the imprisoned lyncher (Cooper has spoken with the man in jail, and the man is repentant. He gives Cooper information to find the rest of the mob.) The judge agrees, so Cooper puts back his badge and heads after the last two lynchers.

Thanks Joseph C!