The heartburn drug Zantac has been on the market for decades, and was considered safe enough to be sold over the counter and regularly given to infants.But last week, the Food and Drug Administration said that it had detected low levels of a cancer-causing chemical in samples of the drug, which is also known as ranitidine. The agency advised patients who were taking over-the-counter versions of Zantac to consider switching to other medications.On Wednesday, the drug maker Novartis said that its generic-drug division, Sandoz, had stopped distributing ranitidine worldwide as it investigates the issue. Novartis and other companies, including Sanofi, which manufactures the brand-name version, have stopped short of recalling their products in the United States.

The F.D.A. said Friday that it had detected a type of nitrosamine called N-nitrosodimethylamine, or NDMA, in all of the samples that it tested.

NDMA is the same chemical that was found in some versions of valsartan, a blood-pressure drug carrying the brand name Diovan. The discovery of NDMA in valsartan led to several recalls of that commonly prescribed drug, which in turn led to supply shortages.Nitrosamines can cause tumors in the liver and other organs in lab animals, and are believed to be carcinogenic in humans. NDMA, which is also found in foods like grilled meat, can form during manufacturing if the chemical reactions used to make the drug are not carefully controlled and monitored, the F.D.A. has said.

The F.D.A. has said it is not telling people to stop taking Zantac, but recommended that patients who take prescription forms of the drug and want to switch should talk to their doctor about alternatives. People who are taking over-the-counter ranitidine should consider taking one of several other heartburn drugs that are available.

“You always want to err on the side of caution,” said Dr. Gary LeRoy, a family practitioner in Dayton, Ohio and the president-elect of the American Academy of Family Physicians. He said there are several alternative heartburn medicines that people can consider.Still, “consumers have to understand that if they’re eating cured meats” and other foods, they are also exposed to low levels of NDMA, he said. “It’s important that they understand we’re not talking about their taking pills that are going to immediately cause them to have cancer, but we need to proceed with caution.”

What is the problem?

I take Zantac, or someone in my family does. What should we do?