Subway vigilante Bernie Goetz, who ignited a national furor over racism and gun control after he shot four panhandling youths on a train in the 1980s, has been arrested on drug charges, police said Saturday.

Goetz was nabbed in a sting operation in Union Square park Friday afternoon for selling $30 worth of pot to an undercover officer, police said. He asked the woman if she wanted to get high, then went back to his apartment, where he has lived for decades, and returned with marijuana, authorities said. He was arrested on charges of criminal sale of marijuana.

Goetz wasn’t being targeted specifically; he just happened to cross paths with the undercover officer assigned to crack down on drug dealing in the park, authorities said.

The 65-year-old was in custody awaiting arraignment Saturday and not reachable for comment.

Goetz became a household name as the skinny, bespectacled white man who, on Dec. 22, 1984, rose from his seat on the No. 2 train in Manhattan and shot four black teens inside a subway car with an illegal handgun. The teens had sharpened screwdrivers and were asking him for $5. Goetz said it was self-defense and the youths intended to rob him.

The shooting brought to the surface long-smoldering urban issues of race, crime and quality of life. It also thrust Goetz, a self-employed electronics expert, into the role of spokesman for what some New Yorkers considered a justified form of vigilantism.

The era was vastly different. Subway cars were spray-painted with graffiti tags and inhabited by muggers, panhandlers, junkies and the homeless. And crime was out of control — there were about 40 felonies per day in the nation’s largest mass transit system. Last year, there were about eight per day, and the figure is declining.

Goetz was cleared of attempted murder charges in 1987 and spent 250 days in jail the same year for a weapons conviction in the case.

In 1996, a Bronx jury awarded one of the teens, Darrell Cabey, $43 million in his lawsuit against Goetz. Cabey’s attorney, Ron Kuby, said Saturday his client remains paralyzed in a wheelchair and has never received a penny from Goetz, who had declared bankruptcy.

Goetz slipped into relative obscurity, surfacing infrequently, as in his 2001 failed bid for mayor.