An Internal Affairs captain who helped oversee the investigation into the Bronx ticket-fixing scandal was hauled off in handcuffs for allegedly beating his sergeant girlfriend into unconsciousness yesterday, The Post has learned.

When McFarlane pulled up in her 2006 Nissan Altima, Wright came out of the shadows and twice kicked the driver-side door, the sources said. Then he slugged her so hard with his right fist that she lost consciousness, according to court documents.

The next thing McFarlane remembered was being lifted off the ground by a uniformed cop with her left eye and jaw swollen and bruised, court papers and sources said. She was rushed to Jamaica Hospital.

McFarlane later told cops that a stranger in a black Explorer got out and punched her, sources said.

But when investigators reviewed surveillance video, they saw a discrepancy in her account, sources said.

Cops questioned her again, and she said the attacker was her cop boyfriend. Wright was cuffed yesterday at his home in Queens Village.

“I know I f–ked up. I know I shouldn’t have done that,” Wright told cops, according to court papers.

He was released last night after his arraignment on charges of criminal mischief, harassment and assault.