(CNN) -- Long before drug cartels, crack wars and TV shows about addiction, cocaine was promoted as a wonder drug, sold as a cure-all and praised by some of the greatest minds in medical history, including Sigmund Freud and the pioneering surgeon William Halsted.

According to historian Dr. Howard Markel, it was even promoted by the likes of Thomas Edison, Queen Victoria and Pope Leo XIII.

It was an explosive debut that would be echoed a century later, when cocaine re-emerged as a different kind of miracle drug, the kind that could let you party all night long with no ill effects and no risk of addiction. Each time, the enthusiasm was misplaced and the explosion left a wreckage of human lives behind.

In 1884, Sigmund Freud was a young physician in Vienna, struggling to make a living even as he dreamed of being a world-famous medical pioneer. He just needed a discovery -- and he thought he had it.

"If all goes well," he wrote his future wife, Martha, "I will write an essay on it and I expect it will win its place in therapeutics by the side of morphine and superior to it. ... I take very small doses of it regularly against depression and against indigestion and with the most brilliant of success."

Dr. Howard Markel: Freud's cocaine problem

Freud wasn't the first to write about cocaine. The drug is derived from the coca plant, where natives in South America had been chewing the leaves for centuries.

By 1880, a number of companies had succeeded in creating a concentrated version: cocaine hydrochloride -- that would set the world reeling.

"It was tens to hundreds of times more powerful than chewing on a coca leaf," Markel says. "It was extremely pure and extremely powerful."

In the 1880s, medical literature consisted of case reports: doctors writing about their trial and error with individual patients. By the early 1880s, there were case reports on cocaine, many published in the widely read Therapeutic Gazette, which was published by Parke-Davis, cocaine's largest manufacturer.

According to Markel, Freud devoured these reports and set himself to writing the definitive tome. The result, in 1884, was "Uber Coca," 70 pages of tribute to the white powder that Freud thought could prove a cure for morphine addiction. ... Somehow in his rapture, he mentioned only in passing that the drug could also serve as a potent topical painkiller -- for which it is still sometimes used.

Halsted, then 32, was already a well-known surgeon in New York when he read Freud's paper and was immediately drawn to explore its uses as a painkiller. Aside from high rates of infection, surgery in the 1880s was a brutal business.

Ether and chloroform were used as anesthetics, but according to Markel, doctors and nurses would have to literally wrestle the patient to keep them down as they administered the choking gas.

Seeking a better method, Halsted began injecting cocaine into his own limbs, as well as those of friends, students and colleagues. While he discovered a valuable means of deadening nerve endings, the findings came at a high price. By the time a patient came in to his operating room a few months later, with a compound leg fracture, the surgeon was a physical and mental wreck.

Says Markel, "(Halsted) was so high on cocaine that he knew he couldn't operate. So he just left the scene, took a cab and went home, and stayed at his townhouse for the next seven months, high on cocaine."

No doubt there were many addicts like Halsted, but in large part their problems were hidden by a wave of positive publicity.

"There were all sorts of health claims being made," says Markel. "If you had a stomach ache, if you were nervous, if you were lethargic, if you needed energy, if you had tuberculosis, if you had asthma, all sorts of things. It was going to cure what you had. And this was how it was advertised, too. Not only by marketers who made these drinks, but by major pharmaceutical houses."

But back then, drugs weren't trapped behind pharmacy walls. Cocaine was sold in drinks, ointments, even margarine. The most popular product was Vin Mariani, a Bordeaux wine developed by a French chemist, with 6 milligrams of cocaine in every ounce -- nearly 200 milligrams in a typical bottle.

In Atlanta, a Civil War veteran named John Syth Pemberton created a copycat wine. Pemberton, who had become a morphine addict after suffering war wounds, was interested in cocaine as a treatment for morphine addiction.

He was also a shrewd businessman. When Fulton County, his Atlanta home, banned the sale of alcohol, he concocted a sweet, nonalcoholic version: Coca-Cola.

In Vienna, Freud's own health was deteriorating due to heavy cocaine use. He suffered an irregular heartbeat and severe nasal blockages. "I need a lot of cocaine," he confessed in an 1896 letter. Soon after, though, he swore off the drug. "The cocaine brush has been completely put aside," he wrote to a friend.

Freud may not have been truly addicted, but he wasn't alone in growing wary of the wonder drug. Says Markel, "By the early 1890s, the medical literature was filled with reports of people who had taken too much cocaine and now had become florid addicts to the stuff."

Halsted was one of them. But it didn't keep him from developing the radical mastectomy, as well as techniques that led to sharply reduced rates of complication and infection. Among other things, Halsted invented the rubber surgical glove.

The advertisements went away. By 1903, there was no more cocaine in Coca-Cola. By 1914, the drug was often seen as something for undesirables -- and often, mixed up in ugly stereotypes.

An infamous article in The New York Times, by the physician Edward Huntington Williams, warned of a new danger: "Negro cocaine 'fiends.' " Williams described a North Carolina police chief who claimed his regular ammunition had little effect on these drug users, and had switched to larger bullets.

Wrote Williams, "Many other officers in the South, who appreciate the increased vitality of the cocaine-crazed Negroes, have made a similar exchange for guns of greater shocking power for the express purpose of combating the 'fiend' when he runs amuck."

Later in 1914, Congress passed the Harrison Narcotics Act, banning the nonmedical use of cocaine, as well as other drugs, like marijuana. Cocaine's long career as an outlaw had begun.

Once banned, cocaine was largely off the radar, although Markel says there was an uptick in use during Prohibition. By the 1970s, the stories of criminals and addicts were largely forgotten.

With the forgetting came an explosion in use that would surpass the one a century before. Again, it started with the elite. "To be a cocaine user in 1979 was to be rich, trendy and fashionable," says Mark Kleiman, a professor of public policy at the University of California, Los Anegeles, and co-author of "Drugs and Drug Policy: What Everyone Needs to Know." "People weren't worried about cocaine. It didn't seem to be a real problem." Of course, it was a mirage.

The last straw for many was the 1986 death of Len Bias, the former University of Maryland basketball star who had just been drafted by the Boston Celtics. Bias died of a heart attack after a night of partying and cocaine use with friends.

As they had a century earlier, lawmakers responded with a ferocity that hit poor -- and nonwhite -- users hardest. In 1986 and again in 1988, Congress passed mandatory sentencing laws that led to an explosion in the U.S. prison population.

"Virtually every state, as well as the federal government, now has some mix of mandatory sentencing," says Marc Mauer, executive director of the Sentencing Project, a group that advocates for poor drug defendants. "Federal prosecutors will tell you it's supposed to be for the large-scale or most complex cases, but the reality is, it hasn't worked out that way."

The laws drew a sharp distinction between crack and powder use. The sale of 500 grams of powder cocaine was punishable by a five-year mandatory prison sentence; just 5 grams of crack would bring the same penalty.

It's a distinction with little rhyme or reason, says Mauer. "It's the same drug."

Since the peak in the mid-'80s, the number of users has dropped by about half, according to the most widely accepted studies. Cocaine use today is dominated by addicts, according to Kleiman, who estimates that 50% to 60% of all cocaine is consumed by people who have been arrested in the past year.

Cocaine has been praised and cursed, not through one but through two frenzied cycles, a century apart. And yet addictive drugs, not to mention the lure of any cure-all drug, can have a serious sway on perception.

Freud never acknowledged the role of cocaine in his physical ills, Markel says. "It's amazing what people will do to deny the dangers of the things they tend to like."