The bigot who randomly attacked two gay men in Williamsburg — hurling a slur at them and then knocking them unconscious — is an Ernst & Young consultant who was arrested Wednesday, according to police and the company.

Brandon McNamara, 25, turned himself in at the Seventh Precinct — home to the NYPD’s Hate Crimes Task Force — around 8 a.m. with his lawyer, police said.

McNamara of Queens attacked the openly gay men — ages 29 and 30 — as they were walking from the Metropolitan Bar in Brooklyn early Sunday, police said. He called them “f—–s” before knocking them unconscious, according to police and witnesses.

“He just sucker-punched me and was a drunk a–hole,” the 30-year-old victim, who asked not to be identified, told The Post in recounting the assault

That victim was taken to Bellevue Hospital with a fractured shoulder, while the other attacked man was taken to Woodhull Medical Center for a broken finger.

McNamara was charged with assault as a hate crime, two counts of assault, aggravated harassment as a hate crime and harassment as a hate crime in the first and second degrees, police said.

McNamara works as a senior consultant at Ernst & Young, according to his LinkedIn page, which has since been deleted.

“Brandon McNamara has been suspended from the Firm pending the active investigation of this matter. The alleged conduct is abhorrent to all EY stands for including our culture of diversity and inclusion. We refer all inquiries to the local authorities”, a spokesperson for the company told the Post.