Legend has it that coffee was discovered more than a thousand years ago by an Arab goatherd who needed to stay awake for an all-night prayer vigil. Having noticed that goats who ate the berries of a certain plant would frolic all night, he concocted a brew that came to be named after the Arabic word for wine: "kahwa."

What got the legendary goatherd through his Arabian night was caffeine, the active ingredient in coffee and tea -- and now the most widely used drug in the world.

A fine, white powder with a bitter taste, caffeine is in a group of chemical compounds called methylxanthines that occur naturally in more than 60 species of plants, including coffee and cocoa beans, tea leaves and cola nuts.

"Most people don't realize how much caffeine they consume," said Dr. John Greden, chairman of the psychiatry department at the University of Michigan Medical Center and an expert in the relationship between caffeine and anxiety.

It's in coffee, it's in tea. It's in chocolate and most soft drinks. It's in baked goods, frozen dairy products, gelatins and puddings. And it's in more than 1,000 prescription and over-the-counter drugs, including Anacin, Darvon, Dristan, Excedrin, Midol and NoDoz.

A single dose of Excedrin can contain as much caffeine as two cups of instant coffee, according to Consumer Reports magazine. A six-ounce glass of Mountain Dew or Sunkist orange soda drunk by a toddler carries the adult equivalent, on the basis of body weight, of a cup of brewed coffee.

During the past 15 years, caffeine has come under increasing scrutiny for its possible health effects -- from ulcers to cancer, from anxiety to zits. Hundreds of studies have been done, with sometimes-contradictory results.

Although these studies have produced no "smoking pistol" evidence of lasting harm to people who consume caffeine in moderation, concern persists. Caffeine has so many known physiological effects -- and so many consumers -- that any potential risk looms large.

Partly because of health concerns, per-capita consumption of coffee among Americans has been falling for a generation, from 3.12 cups a day in 1962 to 1.83 last year, the lowest ever recorded. But consumption of soft drinks, most of which contain caffeine, has more than doubled during the same period.

Soft drinks overtook coffee last year as Americans' most popular beverage (59 percent to 55 percent), the National Coffee Association reported. The average American drinks 34 gallons of soft drinks a year, compared with 28 gallons of coffee, though coffee remains the leading source of caffeine.

An estimated 2 million pounds of caffeine is extracted every year from coffee beans in this country to produce decaffeinated coffee. Most of the extracted caffeine is sold to soft drink manufacturers, who add it to soda brands from Coke to Mello Yello.

Until the 1970s, cola drinks, such as Coca-Cola, and pepper drinks, such as Dr Pepper, were the only soft drinks containing caffeine. (The Food and Drug Administration requires a certain amount of caffeine from the cola nut in soft drinks with "cola" or "pepper" on the label.) But less than 10 percent of the caffeine in cola drinks comes naturally from cola nuts; the rest is added.

Caffeine is included on the FDA's GRAS (generally regarded as safe) list of more than 400 commonly used food additives. In 1978, a scientific panel reviewing the GRAS list found no "clear-cut evidence" that caffeine added to soft drinks was a public hazard but recommended that it be removed from the list because of persistent "uncertainties" about its safety. The FDA then proposed removing caffeine from the GRAS list and placing it on an "interim" list allowing continued use until further studies could settle the issue, but the proposal was never implemented.

"It's the only drug in our food supply," said Michael Jacobson, executive director of the Center for Science in the Public Interest, a nonprofit group that has unsuccessfully petitioned the FDA to require warning labels on caffeine-containing foods and drinks.

Like all drugs, caffeine is toxic if consumed in excessive amounts. The fatal dose in humans is between five and 10 grams -- the equivalent of about 75 cups of coffee, 125 cups of tea or 200 cans of cola.

Even in much smaller amounts, it causes an array of physiological changes. Within half an hour after it is swallowed, the caffeine in a cup of coffee or tea or a can of Diet Pepsi is absorbed through the intestines into the bloodstream and reaches every major organ system in the body.

As a stimulant, caffeine has a direct effect on the brain and the central nervous system. The best-known effect is the oft-touted "lift" that helps millions of Americans get going in the morning. Another effect, well known to anyone who gulps down a mug of coffee just before a long meeting, is that caffeine is a diuretic -- it boosts urine output.

But it also can ward off drowsiness, improve alertness and speed reaction times in people who are tired, and increase muscles' capacity for work. (It can also lead to nervousness, anxiety, jitteriness and loss of sleep; it cannot, however, offset the intoxicating effects of alcohol.)

Caffeine is enough to keep an epidemiologist up nights. It's difficult to study because its effects are so varied, and because they are influenced by so many other factors. These factors, known as "confounding variables," include not only dose (which in turn depends on the grind of the bean or the cut of the tealeaf and the style and duration of brewing), but age, sex, time of day, medical history and whether the caffeine consumer is pregnant, smokes or takes other medications.

"Studies have shown," notes the University of California at Berkeley's Wellness Letter, "that caffeine raises, lowers or does not alter blood pressure; increases, decreases or does not alter heart rate; stimulates respiration or does not affect it; raises or does not raise metabolic rate; raises or does not raise blood glucose concentration; raises or does not raise cholesterol levels."

"It depends on the dose. It depends on the person. And it depends on the state the person is in at the time they take it," said Dr. William Beaver, pharmacology professor at Georgetown University Medical Center.

Depending on the dose and the individual, for example, caffeine can relieve headaches (by constricting the blood vessels to the brain) -- or cause them (by agitating the nervous system).

Some people develop a physiological tolerance for caffeine, and feel its effects less acutely (another reason why caffeine is so difficult to study).

"Someone who isn't used to caffeine -- that person takes a couple of cups of coffee, and they might have a night of insomnia," Beaver said. "Someone else, who's used to drinking coffee, rolls in and sleeps like a log."

Because caffeine is mildly addictive, tolerance can turn into dependence. People tend to become dependent on caffeine at daily doses of more than 350 milligrams, or about 3 1/2 cups of brewed coffee, said Bambi Batts Young, a biochemist and director of the environment and behavior project at the Center for Science in the Public Interest.

Caffeine-dependent individuals who suddenly stop drinking coffee can suffer withdrawal symptoms including lethargy, irritability, nervousness and severe headaches, Young said.

"It is a bad idea to go cold turkey," she said. "It's much smarter to taper off."

Caffeine affects the brain by interfering with neurotransmitters, the chemical "messengers" that help billions of brain cells talk to each other. In particular, researchers at Johns Hopkins School of Medicine in Baltimore found that it gets in the way of a neurotransmitter called adenosine, which normally has a natural tranquilizing effect on the brain.

Neurotransmitters such as adenosine work by attaching to receptor sites on a brain cell, the way a key fits into a lock. But caffeine, which is similar in chemical structure to adenosine, latches onto adenosine's receptor sites like a copied key. That blocks adenosine from exerting its normal calming influence on the brain. The result is heightened activity and alertness or -- in a caffeine-sensitive person who takes too high a dose -- the jittery feeling known as "coffee nerves."

"It was known that caffeine could block the adenosine receptors," said Dr. Solomon Snyder, director of the neuroscience department at Johns Hopkins. "But nobody could really study this until you could measure adenosine receptors in a test tube."

Snyder's group figured out a way to do that, and in experiments on mice found what he calls "a beautiful correlation" between caffeine's potency in blocking adenosine receptors and its potency in stimulating activity in the mice.

In high doses, caffeine also can lead to "caffeinism" -- an anxiety-like pattern of symptoms including nervousness, tremors, agitation, irritability, weakness and headaches.

More than half the people who consume the equivalent of seven or eight cups of coffee a day will experience anxiety-like symptoms, said Michigan psychiatrist Greden, an expert on caffeinism.

"It does it in normals people who aren't chronically anxious ," Greden said. "It does it in anxiety patients at lesser doses. It does it in panic-attack patients.

"But if you stop the drug caffeine , the syndrome goes away."

Much of the recent concern about caffeine has involved the possibility of long-term risk. Some animal studies have implicated caffeine in birth defects, heart disease and cancer, though the scientific evidence of risk in humans is unclear.

Caffeine is hardly a health hazard on the order of, say, smoking. Most experts agree that moderate use -- the equivalent of two cups of coffee a day or less -- poses little or no hazard to most adults.

"I'm not impressed with caffeine being especially dangerous when it's used in limited amounts," said Johns Hopkins' Snyder.

People who consume moderate amounts of tea or coffee, a scientific council of the American Medical Association concluded, "probably need have no concern for their health relative to their caffeine consumption, provided other life-style habits (diet, alcohol consumption) are moderate as well."

The AMA council opposed caffeine-contents labeling of foods and beverages because the caffeine content in tea and coffee is too variable and the caffeine content in other foods accounts for such a small portion of total caffeine consumption.

"There's controversy about all these effects," said CSPI's Jacobson. "There's no conclusive proof. It's not a blockbuster, but it has effects on some people, and people ought to pay attention to that.

"We shouldn't wait until there's a thalidomide before we do anything."

The evidence, he said, warrants a cautious approach to caffeine consumption by those who are particularly susceptible to its effects -- including children, pregnant women, people with heart disease and those who have trouble sleeping.

"It's no great sacrifice -- they could drink decaffeinated coffee," said Jacobson. "Kids could drink -- God forbid! -- orange juice."

Because of the variability of caffeine's effect and the sometimes-inconclusive scientific evidence on its health consequences, doctors are hard pressed to come up with simple advice on caffeine.

"If it keeps you awake, don't drink it. That's pretty straightforward," said pharmacologist Beaver. "But I'm afraid that in a number of these other areas -- such as cancer or birth defects -- the data gets much murkier."