The man who fatally shot a Texas cop as he sat in his patrol car writing a traffic ticket was arrested Monday, authorities said — revealing that the suspect had staked out police headquarters hours before the murder.

Otis Tyrone McKane, 31, was caught near a highway overpass in the San Antonio area.

He had been seen at San Antonio police headquarters at about 7:45 a.m. Sunday, four hours before he shot Detective Benjamin Marconi, 50, authorities said.