The attack occurred at 10:45 p.m. at the state fair in West Allis, Wisconsin, as Barrett was leaving the event with his family.
According to Milwaukee Police, Barrett heard a woman crying for help.
When he began calling 911, the man who had been attacking the woman charged at the mayor and began battering him with a metal pipe, according to a statement released by the Milwaukee Police Department.
The suspect then fled the scene.
Barrett was alert and talking when he arrived at the hospital for treatment, according to police. The woman involved in the incident was not injured.
Milwaukee police are assisting the West Allis authorities in trying to track down the suspect.
No arrests had been made as of Sunday morning.