Two Brooklyn street punks picked the wrong guy to rob.

An off-duty NYPD detective was headed to work Sunday night when he was confronted by the thugs — one simulating that he had a gun and the other wielding a cane — and wound up fatally shooting one of them, police said today.

Antwain White, 17, a reputed gang member in foster care, and his 15-year-old accomplice jumped off-duty cop Benjamin Cintron, a 26-year veteran, near 22 Grove St. as the officer was heading from his home in Bushwick at 11:50 p.m. to work the overnight shift, cops said.

The perps only knew that their target was 50 years old and at 5-foot-6 and 155 pounds — no match for the two of them, especially since White was armed with a wooden cane with the rubber tip removed to make it more of a weapon, police said.

White ordered Cintron to “run his pockets” — empty them — sources said.

The accomplice, simulating that he had a gun, then grabbed the officer’s arm while White smashed the cop on the left side of the head, authorities said.

Cintron said he was a cop and took out his detective shield and sidearm and shouted, “Drop it! Drop it!”, police said.

Fearing the accomplice had a gun and as White hit him again and threatened to strike him a third time, the detective fired once, mortally wounding White in the chest, cops said.

“[The officer] thought he was going to be seriously injured or killed. He had no choice,’’ a law-enforcement source told The Post, adding that after the shooting, the cop “was shaken up.’’

White was declared dead at Woodhull Hospital. The 15-year-old fled but was soon apprehended.

Authorities said White was a member of the Muckers, a gang of about 20 youths that have been terrorizing Bushwick and Bedford-Stuyvesant.

“At night, it’s very dangerous here,’’ said one resident who lives nearby the scene of the shooting. “They make drug transactions. There have been attempted rapes. They set a truck on fire. They break into cars all the times.”

White had been previously arrested for robbery, assault and criminal trespass.

His tearful mother, Crystal White, 33, said, “They took my baby away from me. My son was 130 pounds, and they’re telling me this officer didn’t know how to handle two kids.” , She said her son had been foster care for at least four years.

“He was in the care of the city. They took him from me,” she said.

She said he was put in a group home but had been missing since Sept. 30.

“He was not supposed to be out on the street,” she said.