It began one sultry summer morning four years ago, just before dawn, when masked police officers swept through the poorest neighborhoods of this sun-stunned rural town in northern Texas arresting dozens of people on drug charges. By the time they were done, about a tenth of Tulia's tiny black population was in jail and the town had been ripped to pieces.

Many here -- black and white -- fervently hope it will all end this afternoon, when most of the convicts still imprisoned from that now-notorious sweep are expected to go free. Among the 13 is an illiterate 60-year-old hog farmer of no discernible wealth who was sentenced to 90 years for dealing cocaine based on the uncorroborated testimony of one white undercover officer who has admitted to using racial slurs.

"It wasn't about drugs," said Freddie Brookins Sr., whose son Freddie Jr., a former high school football and track star with no prior criminal record, received a 20-year sentence. "It was about getting rid of a group of blacks, young males. I refer to it as ethnic cleansing."

Conceding that the lone undercover officer was unreliable and that the arrests amounted to a travesty of justice, Texas prosecutors moved this spring to throw out the 38 convictions that resulted from the 1999 sweep. A judge agreed, and last month Gov. Rick Perry (R) signed a bill allowing the remaining inmates to be released pending an appeals court review.

And so today, flanked by a phalanx of civil rights lawyers from New York, Washington and Texas, they are to walk out of the same courthouse where they were sentenced -- and straight into the glare of a national media circus.

"It's going to be a wild day, a tremendous day, a rejoiceful day," said Brookins, 49, a thoughtful man with a gray goatee. "We've been waiting for this for four years, and it's finally come."

A cotton- and grain-farming town of 5,000 people, Tulia is a flat, hot, dusty place midway between Lubbock and Amarillo in the Texas Panhandle, a part of the state sometimes called "the Big Nothing." Drought and low crop prices have sapped the local economy; some of the town's grain elevators, built by Italian POWs during World War II, are no longer used. The marquee of the only movie theater in town advertises a show called "Fussin' an' a-Feudin'," and the obelisk in the broad, silent courthouse square touts Tulia as "a city with a future."

But the tenor of that future is now in doubt. The drug sweep remains a deep schism running through this town, a barrier that is invisible but every bit as divisive as the Berlin Wall.

At the center of the story of the sting operation is the undercover officer who ran it, a slight, ponytailed, itinerant lawman named Thomas Coleman. His 18-month investigation led to the arrests of 46 people, 40 of them black -- even though he could supply no fingerprints, audio or video surveillance or corroborating witnesses, and the busts turned up no drugs, weapons, paraphernalia or other evidence of drug-dealing.

Much of the sting has been discredited. Coleman, 43, who later admitted to using racial slurs and scribbling crucial notes on his leg, now faces charges of lying under oath about stealing gasoline in 1998, when he was working as a sheriff's deputy in another county. His background includes leaving nearly $7,000 in bad debts before skipping town in a previous job and failing to pay child support.

In a court-ordered hearing on the Tulia case in March, he gave rambling, vague answers when challenged on his background, techniques and the scant evidence he had presented. At one point he conceded that "there were some mess-ups" in some of the Tulia cases.

But to many people in Tulia, Coleman arrested the right people. One who believes that is Brenda Marshall, 48, who works at Dorothy's Good Ol' Fashioned Food, a local eatery. She is so disgusted by the releases set for today that she says she will not watch the television news tonight.

"I don't care what they say, my neighborhood's a lot quieter than it was," she said. She used to shop at a convenience store, but said, "I hated to go there because of all the blacks that were out front. Now you don't have to worry about them all being out there."

Her friend Debbie Earl, who served on the jury that sentenced Freddie Brookins Jr. to 20 years, was torn about the trials, but is not contrite now. She hated to condemn a young man to prison -- she had worked for years at the high school with Brookins's grandmother -- but he had not been able to prove his alibi, she said. She added that as a juror she knew nothing of Coleman's checkered background, much of which the judge had sealed.

The view that some or many of those who were convicted were guilty and deserved to go to prison -- even if the cases against them may have been flawed -- appears widespread in Tulia, and it is not confined to the white community. Many blacks are furious about what they say was a decision by law enforcement authorities to target them in the sweep, but some concede that drug use, especially crack cocaine, has been an affliction here.

"Some of them, they just got the wrong name on the wrong face," said Elizabeth Yarbrough, 66, who is black and the grandmother of 14. "But some of them, they deserved to be gotten."

But that is not the point, say defense attorneys, who have donated what some estimate at several million dollars' worth of legal work to the case. They contend that the arrests, prosecution and trials were the consequence of a local legal system that preyed on poor, vulnerable defendants, a determination to crack down on drugs with little regard for the niceties of due process, and venomous racial stereotyping by small-town jurors.

For years before the 1999 busts, local newspapers dwelled on the drug scourge, the clergy railed against it, politicians ran against it and law enforcement officers promised to clean it up. After the sweep, one newspaper applauded the crackdown on "scumbags." Lana Barnett, the president of Tulia's Chamber of Commerce, told the Amarillo Globe-News, "What we've got is a bunch of low-lifes who got caught and are whining about it."

Lacking money to hire private attorneys, most of the defendants made do with court-appointed lawyers. In the eight cases that went to trial, just one of the 96 jurors was black; the others were white or Hispanic. The sentences that jurors handed down ranged from 20 to 90 years.

Vanita Gupta, an attorney for the NAACP Legal and Education Fund in New York who is handling the defense for many of the Tulia convicts, has interviewed some of the former jurors. "There's supposed to be a presumption of innocence," she said. "What we discovered is that there was more a presumption of guilt. . . . It was a railroading of an entire community in a very short amount of time."

The busts have left a bitter taste for many in the black community, which numbers fewer than 500. Many blame the local sheriff, Larry Stewart, and the district attorney, Terry McEachern, for protecting Coleman, portraying him publicly as trustworthy and professional and arranging lightning-fast trials that resulted in draconian sentences.

"We were poor black people, we couldn't get a lawyer," said Michele Williams, 35, a mother of four who pleaded guilty and served a two-year sentence, although she says she never used or sold cocaine.

Stewart, who hired Coleman, declined to be interviewed on the record about the case, other than to say Tulia is "a fantastic community."

McEachern was convicted of drunken driving in New Mexico and was in jail there last week.

A few whites in Tulia became champions of the people swept up in Coleman's sting. They have been shunned by Tulia's white establishment, which is resentful that the town has been painted as racist. Many whites in Tulia seem to regard outsiders as the enemy. Others insist that if something went wrong, it was all the fault of one rogue cop. Few acknowledge that innocent people may have spent four years in prison.

"It depends what your definition of justice is," said the Rev. William Guenther, pastor of the Assembly of God Church, who was foreman of a jury that sentenced one man, Jason Jerome Williams, to 45 years in prison. "I think he's being released according to the law. I think he was sentenced according to the law. I look at it like the system worked."

The convictions of the 38, all but 10 of whom pleaded guilty after local juries began handing down blisteringly tough sentences, will stand until they are overturned by an appeals court or vacated by a pardon from the governor.

As for the relatives of those who are to be freed today, they are breathlessly excited. Michele Williams, who has several cousins who are to be released, as well as a son- and daughter-in-law, is wondering how to do her hair and what to wear to greet them. Freddie Brookins Sr. is planning to take a week off work to be with his son. They might do some fishing.

"It's like a part of you has been missing," he said. "You go to work thinking about it, you come home thinking about it, you go to sleep thinking about it. These past four years, we've been incarcerated on the outside."

Special correspondent Karin Brulliard contributed to this report.

Scars from the 1999 drug sweep are still deep in the small community of Tulia, Tex., a cotton- and grain-farming town of 5,000 people.State Rep. Terry Keel (R-Austin) speaks to the media after Gov. Rick Perry (R), right, signed a bill, sponsored by state Sen. John Whitmire (D-Houston), left, that allows for the release of the people imprisoned in the Tulia drug sweep.