LAST MONTH, in a packed courtroom, the mayor of the District of Columbia stood before a federal judge and got a six-month sentence for one misdemeanor count of possessing cocaine. The sentence outraged Marion Barry's supporters; the mayor called his treatment an example of "the American injustice system."

Five days later, in a nearly empty courtroom in the same building, another first offender stood before another judge after being convicted of possession with intent to distribute more than 50 grams of crack and selling it within 1,000 feet of a school.Keith Jackson, 19, got a sentence of 10 years in prison without parole.

Barry and Jackson have some things in common. Both are first-time drug offenders convicted in well-publicized cases. But the stark differences in their treatment point to a little-understood fact about the federal criminal-justice system: While it was Barry's punishment that prompted public debate, it is the sentences given to the Keith Jacksons of the world that are the harsh and unmistakable reality of the drug war in the nation's courts.

Barry's case was based on allegations of drug use going back to 1984 and included charges of lying to a federal grand jury. Jackson's notoriety was briefer. In September 1989, undercover federal agents lured him to Lafayette Park across the street from the White House -- hardly a hotbed of drug activity -- to sell a bag of crack. That plastic baggie was later held up by President Bush on nationwide TV during a major anti-drug speech -- a gesture that for many symbolized how the drug war was fast devolving into political theater.

Jackson was eventually acquitted for the Lafayette park sale. But he was convicted of three other drug counts and, under tough new federal sentencing laws, U.S. District Judge Stanley Sporkin said he had no choice but to imprison him for the next decade even though he thought it was too harsh. Over the past six years, Congress and state legislatures have enacted a series of stringent anti-drug laws that have dramatically increased the penalties for even relatively minor drug crimes. The result: an overwhelmed court system and staggering increases in the nation's prison population. But equally serious, in the eyes of many judges, is a form of robotic justice which metes out harsh penalties every day to low-level offenders -- most of them poor, young and members of minority groups.

"I can't continue to do it -- I can't continue to give out sentences that I feel in some instances are unconscionable," said U.S. District Judge J. Lawrence Irving of San Diego, a Reagan appointee who recently announced he will resign next January in protest over the federal sentencing laws. "Every week, I get these cases of 'mules' -- most of them Hispanic -- who drive drugs across the border. Ninety percent of the time they don't even know how much they're carrying -- they met somebody in a bar who paid them $500. If it's a couple of kilos, you hit these mandatory minimums and it's unbelievable . . . . You're talking 10, 15, 20 years in prison."

Nor are such views unusual on the bench these days. "I think you'll find that a good number of judges are opposed" to these sentences, said Sporkin. One federal judge interviewed last week wondered, only half jokingly, whether in years to come he and his fellow jurists will have to assert the Nuremberg Defense -- "I was only following orders" -- to justify the number of people they are sending to prison for decades.

This week, the Supreme Court will hear arguments in the case of Gary Harmelin, a 45-year-old former Air Force honor guard, serving a mandatory life sentence in a Michigan state prison for possessing 673 grams -- about 1.8 pounds -- of cocaine. Lawyers for Harmelin argue that Michigan's law, which mandates life for anything over 650 grams, constitutes "cruel and unusual" punishment under the Eighth Amendment to the Constitution.

But while Harmelin's may be an extreme example, state and federal court dockets are bulging with cases of people who were poor, gullible or greedy enough to be talked into working for higher-level drug merchants: In July, Sarita Brevard, a 19-year-old welfare mother from Brooklyn, was sentenced to five years in prison after being arrested at Washington's bus terminal while carrying 30 grams of cocaine. Brevard had been paid $300 for the trip. "She wasn't even a user," said her lawyer.

Last November, Jose Antonio Cabalero, 19, a former stock clerk at The Wiz record store in Manhattan, was caught by police at the Greyhound bus station with 245 grams of crack in a Cheese Nips box. Cabalero, who had never been arrested before, got 10 years. In March, Carla Thomas, a 24-year-old mother of three, was caught carrying 4.4 pounds of cocaine at the St. Louis bus station after her boyfriend, who beat her regularly, ordered her to deliver the drugs to three men she didn't know in Los Angeles. Her sentence: 11 1/2 years. The trend toward such sentences began in 1984, but it rapidly accelerated with the Anti-Drug Abuse Act of 1986 enacted during the summer that Len Bias died of a cocaine overdose. Under that act, punishment for drug offenses became mechanical: 10 years for 11 pounds of cocaine, 2.2 pounds of heroin or 1.7 ounces of crack. A 1988 act stiffened sentences even further. Sell crack within 100 feet of a youth center, playground, swimming pool or video arcade, and the sentence doubles. Get caught possessing 1.7 ounces of crack, barely a teaspoon, and you get five years.

"The way in which these sentences were arrived at -- it was like an auction house," recalls Eric Sterling, a staff member on the House Judiciary Committee when the laws were being written and currently president of the Criminal Justice Policy Foundation. "It was this frenzied, panic atmosphere -- I'll see your five years and I'll raise you five years. It was the crassest political poker game. Nobody looked and said these sentences are going to have the following effect on the courtrooms around the country, on street corners and on the prisons."

But those effects are now rippling through the criminal-justice system -- at enormous cost. The Justice Department recently reported that the nation's federal and state prison population soared by 42,862 inmates during the first half of 1990 to reach a record 755,425. The federal system alone has ballooned from 23,000 inmates in 1980 to nearly 60,000 today, with projections that the figure will exceed 100,000 by the mid-1990's. One-fourth of the nation's black men between the ages of 20 and 29 are now in prison, on parole or on probation, according to a recent report by the Sentencing Project.

In the past two years alone, the average sentence for inmates convicted of drug offenses -- which now comprise well over half the number of new inmates -- has increased from 58 to 77 months. At current projections, each new inmate will cost taxpayers $109,000. Jackson's 10-year sentence will cost $170,000.

For Bush administration officials, none of this is disproportionate. "I don't have the same sense of empathy for someone selling poison," said high-ranking federal drug official and former D.C. Superior Court Judge Reggie Walton after Sporkin expressed concern about Jackson's sentence. "I have seen the effects that selling drugs is having on the community. I don't know to what extent Judge Sporkin has gone out and seen the babies addicted to drugs . . . . God knows how many people {Jackson} sold drugs to before he got caught."

But to many judges and prosecutors, such arguments miss the point. In a recent letter to Congress lobbying against proposals for yet stiffer mandatory sentences, 4th U.S. Circuit Court of Appeals Judge William W. Wilkins, noted that such sentences "do not permit consideration of an offender's possibly limited {or} peripheral role in the offense." As a result, many judges say, the laws can actually work to the advantage of big-time drug offenders.

Under the terms of federal sentencing guidelines, a judge is allowed to give a more lenient sentence than the mandatory minimum only if the prosecutor files a motion saying that the defendant has rendered "substantial" assistance to the government in nailing other drug suspects.

But only high-level traffickers can provide such help; the couriers usually know next to nothing. "There is an inequity for the person who can't deliver the goods," said Peter Djinis, a former Justice Department narcotics prosecutor.

The result, says Irving, are the kinds of disparate sentences he was forced to give out just last week. A bit player in a marijuana smuggling conspiracy that ultimately went awry -- no drugs were ever imported -- received 10 years. The ringleader, who after being arrested cooperated with the government and fingered other drug dealers, got four and one half. "That was the biggest joke of all," said Irving. "The first guy is the first-time, poor offender, and he doesn't know anything . . . . The other guy sang like a canary" and got a substantially reduced sentence.

By the time he was convicted last January, Keith Jackson knew what was facing him. Moments after the jury delivered its verdict, observers said, the young man threw himself screaming on the floor of the holding cell behind Sporkin's courtroom. He eventually had to be subdued by federal marshals with a straitjacket.

Jackson's only chance at leniency was cooperating with the government, but Assistant U.S. Attorney Mark Carroll told Sporkin that hadn't happened, and that in fact Jackson "denies his true culpability." Another source knowledgeable about the case hinted after the hearing at another motive: that Jackson didn't talk because he might have incriminated a family member.

In the end, the only advice Sporkin could offer was to ask President Bush, whom he called "a man of great compassion," for a commutation of his sentence. Jackson's attorney, Charles Stow III, said he intended to do just that.

But success seems doubtful. After Jackson's arrest, Bush was asked about the incident. "The man went there and sold drugs in front of the White House didn't he?, said Bush. "I can't feel sorry for this fellow . . . . I mean, has somebody got some advocates here for this drug guy?"

Michael Isikoff and Tracy Thompson are Washington Post reporters.