KAUFMAN, Tex. — A county prosecutor in this small town southeast of Dallas was fatally shot on Thursday morning near the courthouse by one or perhaps two gunmen, whom witnesses described as wearing masks, black clothing and tactical-style vests, the authorities said.

The prosecutor, Mark E. Hasse, worked in the Kaufman County district attorney’s office in Kaufman, a town of 6,800 people about 35 miles from Dallas. He was shot several times shortly before 9 a.m. as he walked in an employee parking lot about a block from the courthouse.

The authorities said the suspect or suspects got out of a Ford Taurus, opened fire on Mr. Hasse and then returned to the car and drove away. Investigators were trying to determine why Mr. Hasse was targeted and if the shooting had anything to do with cases he had prosecuted.

“I’ve been doing this 43 years, and I’ve never seen anything like this,” said David A. Byrnes, the Kaufman County sheriff.