The Raleigh Police Department said it happened Monday on Shanda Drive off Spring Forest Road.
In a booking photo, 27-year-old Matthew Lawrence Bergstedt has two black eyes and several facial lacerations.
Police said after the resident hit him, Bergstedt fled and broke into a vacant apartment nearby. He was charged with breaking and entering and attempted breaking and entering.
Police said the incident was not a random act, as Bergstedt was once involved with a relationship with a woman in the apartment he attempted to enter.