Bernhard Goetz — the infamous “subway vigilante” who became part of New York City lore when he shot four youths who he said were threatening him on the subway in 1984 — was busted Friday evening for peddling $30 worth of pot to an undercover female cop, The Post has learned.

Goetz was arrested at 15th Street and Fifth Avenue near his Union Square pad at about 5:45 p.m., police sources said.

“He told her he wanted to get high with her and sold her a small amount of pot in a ­tissue,” a source said.

Goetz, 65, met the undercover on the street, chatted her up and walked with her back to his apartment, where he went upstairs to get the weed.

When he came downstairs to allegedly give her the pot, he was arrested, the source said.

New Yorkers who live and work near the scene of the crime couldn’t believe Goetz had been busted for pot.

“Bernie? Oh, come on, they arrested him for that? It’s just pot, they should let him go,” said doorman John D’Antonia, 71, who works in a building near Goetz’s.

“People will now probably say he shot those kids because he was high.”

Goetz, 65, was walked from the Sixth Precinct station house on West 10th Street early today — with several cops shielding him from the media — and then driven to Manhattan Central Booking.

Cops escorting Goetz into booking screamed at news photographers and reporters to get across the street, and then pulled the van carrying him directly to the courthouse door so he cold not be photographed.

Goetz was expected to be charged with criminal sale of marijuana, a misdemeanor and several other charges, a police source said.