After four years under a mayor who cracked down on homeless people and got tough on crime, San Francisco is returning to its trademark strident liberalism. A new district attorney who favors rehabilitation over revenge is promising to fend off the lock-'em-up mentality so popular elsewhere, and many San Franciscans seem delighted by the change.

Terence Hallinan, a civil rights activist and former war protester who was elected in December, backs legalized prostitution, wants most drug offenders mentored rather than jailed, and has no intention of enforcing California's tough "three strikes and you're out" sentencing law for nonviolent repeat offenders. Along with the flamboyant and unabashedly liberal new San Francisco mayor, Willie L. Brown Jr. (D), Hallinan, 59, is leading what he says is the revival of "old progressives" who champion a kinder and gentler approach to solving intractable social problems such as crime, homelessness and drug addiction.

"San Francisco has always been on the cutting edge of change. I think the pendulum is going to swing the other way, and it's starting right here," the fervently liberal crusader said as he explained his unorthodox views at his favorite workingman's luncheonette near the county courthouse.

Hallinan, whose father once ran for president on the leftist Progressive Party ticket, says he is aware that his agenda runs counter to the national trend of social conservatism. In addition to opposing the "three strikes" law, Hallinan promises to involve gang members in community activities rather than arrest them and has told his deputies they need to get more involved in the community instead of just prosecuting people.

"It's easy to talk tough on crime, but you get to the point where you simply can no longer afford it, not to mention the unjustness of it and the disparate impact it has on minority communities," Hallinan said. "Locking people up and throwing the key away hasn't made people feel safer and more secure. It's just clogging the courts, filling up the prisons and bankrupting us. I want to try something different."

This is especially important in San Francisco, with its liberal traditions, he said. People here want more compassionate approaches to crime and related social problems than those advocated by the House Republicans, for instance, in their "Contract With America." "I think that approach has really turned people off. All over town, people are feeling good about the generally progressive direction we are moving," he said.

Recent polls support his claim. A majority of respondents in one survey, which did not specifically focus on the District Attorney's Office, said they thought the city was "moving in the right direction." Nearly two-thirds said the current city administration was off to a good start. This is in sharp contrast to a poll in April 1994, when only 19 percent of voters said the city was moving in the right direction.

Still, not everybody here is enthusiastic about the revived liberalism.

"There are 58 counties in California, 57 of which have tough district attorneys. Then there is Terence. He is definitely one of a kind," said State Sen. Quentin L. Kopp (I), a conservative former member of San Francisco's Board of Supervisors and outspoken critic of Hallinan's policies. But Kopp said he didn't think Hallinan, or his election, represented the beginning of a new national trend.

"This is and has been for years a left-wing city. I've resigned myself to that. But if you want a forecast, my forecast is a gloomy one. The crime statistics will eventually prove him wrong," Kopp said.

Hallinan said he will be tough on "real crime" -- murder, armed robbery and rape -- and will aggressively prosecute major narcotics traffickers and dealers who sell drugs to minors.

"But let's get the other junk out of the courtroom, the simple possessions and the kid on the street selling a rock or two of crack cocaine. The courts are so cluttered with these cases that when you get real serious crimes, it's a year or more before you can bring them to trial. It's crazy," Hallinan said.

The district attorney said he would like to steer young drug offenders into treatment programs and develop community programs such as midnight basketball or a mentoring program similar to one in neighboring Oakland, where young violators are paired with adults in an attempt to provide good role models.

He said he also would like to reverse a trend recently highlighted in a study by the San Francisco-based Center on Juvenile and Criminal Justice, which found that blacks, who make up only 7 percent of California's general population, comprise nearly a third of the state's prison population. The disparity, Hallinan said, is largely attributable to harsher sentences given to blacks for drug offenses than to whites.

While his point of view has support here, some of Hallinan's moves have drawn criticism, such as firing 14 senior prosecutors -- in part to make room for more minorities on the staff -- by having terse form letters dropped on their desks instead of talking directly with them. The criticism intensified after Hallinan posted an armed guard outside his office for protection against what he said was a danger of retaliation.

Hallinan acknowledged he made a bad mistake in handling the matter, but he said his goals were good ones: getting rid of underperformers and "building more confidence in the courtroom among African American defendants." Hallinan also has ordered his deputy prosecutors not to use peremptory challenges to create all-white juries for their cases, a practice Hallinan said was common in criminal trials.

Hallinan also said he plans to send prosecutors to high-crime neighborhoods to "get to know the people and tell them how they can help their police and district attorneys. We have to break down the barriers of mistrust between the minorities and the criminal justice system."

Hallinan says he is aware that few cities would elect a chief prosecutor with his views. But he said his family history is intimately tied to San Francisco's liberal traditions. Hallinan's late father, Vincent Hallinan, in 1950 successfully defended Harry Bridges, the longshoremen's union leader accused of lying when he denied he was a communist. His mother, meanwhile, was a leader of the leftist Women's International League for Peace who ran her husband's Progressive Party campaign for the presidency while he was serving time in jail for contempt.

The elder Hallinan taught his six sons how to fight, and by the age of 17 Terence had had several scrapes with the law, including a conviction for helping beat up three Coast Guardsmen in order to steal a case of beer. Hallinan channeled his fighting skills into amateur boxing and made it to the 1960 Olympic boxing team eliminations -- in which he sparred with Cassius Clay, who later became world heavyweight champion as Muhammad Ali.

After attending college and law school, Hallinan was active in civil rights campaigns in Mississippi in the 1960s and took part in protests against the Vietnam War. As a lawyer he defended hundreds of young people living in the freewheeling Haight-Ashbury district of this city against drug charges. He freely admits smoking marijuana in his youth, but vehemently denies almost dying from a heroin overdose administered by rock singer Janis Joplin, as claimed in her biography, "Pearl."

In 1988, Hallinan was elected to the San Francisco Board of Supervisors, where he gained attention with his advocacy of liberal legislation, including equal rights guarantees for transsexuals. He also became adept at budget-making, a skill Hallinan said he will need to apply in order to implement his proposed criminal justice reforms.

Hallinan has a long association with Brown, the city's new mayor. He chaired his political youth committee in 1962, at the start of Brown's meteoric rise to speaker of the California Assembly. Hallinan said he has not had time to discuss his agenda at length with Brown since the election, but added, "It's amazing how much we're on the same page without sitting down to work it out. It's a matter of similar orientation, I guess."

The district attorney said he supports Brown's pledge to end the controversial program, launched by former mayor Frank Jordan, in which police issued thousands of arrest warrants in an attempt to drive homeless people and aggressive panhandlers out of parks and other public places. "I'd like to review those warrants and get those people out of the criminal justice system," he said.

Convinced that history is cyclical and that his kind of liberal views are due to return nationally, Hallinan said, "I think Willie Brown and my election are not just a quirk but a reflection that this country is looking for alternative ways to deal with these kinds of problems. Maybe old progs like us can turn things around." CAPTION: San Francisco District Attorney Terence Hallinan, a former amateur boxer, is pursuing a kinder and gentler agenda on social problems such as crime.