A crazed Brooklyn driver rammed into a cop, then drove more than three miles before crashing into a brick wall as police gave chase early Saturday, cops said.

Cops were responding to an assault in a bar at Kings Highway and McDonald Avenue in Gravesend around 5 a.m. when they spotted the 24-year-old suspect in his car, revving up his engine and driving back and forth.

As the officers approached the driver, he took off, hitting one of them, according to police.

He drove with a police cruiser on his tail to Langham Street and Shore Boulevard in Manhattan Beach. He finally came to a stop when he hit a three-foot brick wall in a residential yard.

The officer was taken to NYU Lutheran Medical Center where he was treated for cuts and swelling to his right leg, and released. The driver was not injured.

He was arrested and taken to the 78th Precinct, according to police. Charges are pending.