When "Bill" learned three years ago that a medication normally used to treat multiple sclerosis patients might help save his remaining good eye from macular degeneration, he was eager to try it.
But Bill was surprised to learn that the drug, Copaxone, would cost up to $11,000 per year from a pharmacy in his hometown of New York City. And he would have to pay for that entirely himself. Medicare wouldn't cover even part of the cost because the drug is not approved in the U.S. for macular degeneration treatment.
When he told the price to the ophthalmologist who had written him the prescription, "He said, 'Why don't you try to find a Canadian pharmacy that will sell it?'" recalled Bill, an 81-year-old retired statistician, who requested his real name not be published.
Bill went online and found such a pharmacy. Since then, he has regularly ordered the medication from Canadian outlets, which, after verifying his prescription, have the Copaxone shipped from the United Kingdom to him.
A 28-week supply—one injectable vial per week—most recently cost him $1,200 from a Canadian pharmacy. The last time he checked prices of the same supply at U.S. pharmacies, he saw it would have cost him between $4,500 and $5,550, Bill said.
Read MoreWhy Americans pay more for medicine
Bill said he is happy with the thousands of dollars over the years that he's saved from buying from Canada, and with the effectiveness of the drug, which has kept his eye condition in check.
But Bill's international online shopping violates the law—a fact that he was unaware of until he spoke with CNBC this week.
It is illegal for individuals to import prescription drugs into the United States, with rare exceptions.
And the Food and Drug Administration says: "Medicine bought from foreign sources, such as from Internet sellers, from businesses that offer to buy foreign medicine for you, or during trips outside the United States, may not be safe or effective. These medicines are illegal and may present health risks, and FDA cannot ensure the safety, efficacy and quality of medicine from these sources. FDA cannot help consumers who have problems with medicine obtained from outside U.S. regulation and oversight."
Read MoreFor patients, a priceless treatment
Even with those warnings and the legal prohibition, millions of otherwise law-abiding Americans break the law every year by ordering from Canadian and other international pharmacies, taking advantage of the fact that the cost of prescription medication bought from them can be much less than in the U.S.
The federal government has said about 2 percent of the adult population, or 5 million Americans, have purchased drugs outside the U.S. for such deals. Another 50 million Americans in 2012 reported they did not fill a prescription because of its cost, according to a Commonwealth Fund report.
The online deals include one offered recently by a Canadian online pharmacy selling a 90-day supply of 200-milligram Celebrex pills for $143.75. The same quantity of the arthritis pain medication was on sale from Kmart's pharmacy website for $614.
Last fall, one analysis by a company that accredits international pharmacies found that U.S. consumers on average would save 76 percent on the cost of brand-name medications made in America if they purchased those drugs from international online pharmacies instead of in the U.S.
"For some folks, this is the most viable way for them to fill their prescription at a price they can afford," said Lee Graczyk, lead organizer for the drug importation advocacy group RxRights, whose website contains many testimonials from such people.
Despite the practice being illegal, the FDA does not tend to prosecute people who import drugs for personal use, particularly for amounts that equal only a few months' supply.
"Personal importation is almost always overlooked by the FDA," a recent analysis of online-pharmacy medication noted. The FDA itself says that its enforcement efforts around importation are focused on medication imported for commercial use, fraudulent drugs and products that pose high health risks.
As a consequence, prescription drug importation by individuals for personal use "has been a gray area for some time," Graczyk said.
So gray that in 2004, then-Kansas Gov. Kathleen Sebelius signed an agreement to have her state join Illinois, Wisconsin and Missouri in the I-SaveRx prescription drug importation program. It was "the first program in the nation to allow citizens to purchase lower cost, safe prescription drugs from state-approved pharmacies in Europe and Canada," according to a news release from the governor's office at the time.
"We must make health care and life-sustaining prescription drugs more affordable for seniors and hardworking Kansans. After carefully reviewing the I-SaveRx program, I'm convinced it will help tens of thousands of Kansans safely obtain the medicine they need at prices they can afford," Sebelius said at the time.
The I-SaveRx program later foundered after, among other things, the FDA blocked some drug shipments from Canada. Sebelius, however, went on to be appointed President Barack Obama's first secretary of Health and Human Services, a department that includes the FDA.
But last year, the state of Maine passed a law with bipartisan support that made it legal for residents to buy drugs by mail from retail pharmacies located in Canada, the U.K., Australia and New Zealand.
The move came after state regulators barred imports from a Canadian mail-order drug company, whose prior use by both state and private employees had saved them millions of dollars in costs. As a result of the new law, the state will not interfere with such imports.
South Carolina's legislature is now weighing a similar bill.
The states' actions underscore how—in the absence of aggressive federal prosecution of personal importation cases—advocates and opponents of online international pharmacies have stepped into the vacuum to either encourage or discourage the practice.
Opponents, including the National Association of Boards of Pharmacy, often highlight the risk of buying online from sites that may be fraudulent or selling questionable drugs.
"Rogue websites are all over the Internet selling drugs that are not what they appear to be," the NABP's own site warns. "These sites may be selling drugs that are counterfeit, contaminated, or otherwise unsafe."
NAPB runs its own accreditation program of online pharmacies, and says that out of more than 10,000 sites examined, "only 3 percent of those online sites appear to be in compliance with pharmacy laws and practice standards."
But sites that didn't meet the NABP's accreditation standards include ones that legally operate in their home countries and do dispense legitimate medications.
In fact, NABP's "approved" list includes just 34 online pharmacies, all of which are U.S. based.
Mark Grayson, spokesman for the industry group the Pharmaceutical Research and Manufacturers of America, said the group is "absolutely" opposed to people buying from international pharmacies. "You don't know where the drugs are coming from," Grayson said, referring to the manufacturers who make the medications.
But Peter Maybarduk, director of Public Citizen's Global Access to Medicines Program, took issue with such blanket condemnations of the practice.
"You see a lot of efforts by the pharmaceutical industry trying to paint all online pharmacies with the same brush. I think that's a problem," said Maybarduk. "There are some spurious efforts to inhibit competition."
There are, however, cases of criminal organizations operating purported online pharmacies to defraud consumers.
Last year, the FDA announced that it, in partnership with international regulators and law enforcement, had taken action against more then 9,600 websites that illegally sold "potentially dangerous, unapproved prescription medicines to consumers." More than $41 million worth of illegal medicines worldwide were seized in the action.
"Many of these websites appeared to be operating as a part of an organized criminal network that falsely purported its websites to be 'Canadian Pharmacies,'" the FDA said at the time.
"These websites displayed fake licenses and certifications to convince U.S. consumers to purchase drugs they advertised as 'brand name' and 'FDA approved.' The drugs received as part of Operation Pangea were not from Canada, and were neither brand name, nor FDA approved."
As part of its BeSafeRx program, the FDA does warn consumers that "Buying from fake online pharmacies can be dangerous, or even deadly. Before you order medicine online, it is important to know the risks of buying from fake online pharmacies."
In light of such problems, the company PharmacyChecker.com was created to give consumers some peace of mind when shopping for prescriptions online from overseas pharmacies, while at the same time charging pharmacies for being listed on the company's site.
"We check the legitimacy and license of the pharmacy," said Gabriel Levitt, vice president of PharmacyChecker.com. "To make sure that the pharmacy is selling approved drugs."
In addition to confirming a pharmacy is licensed in its home country, PharmacyChecker.com also posts customer reviews and ratings of pharmacies.
Levitt contends the NAPB and the drug manufacturers, while correct in warning about "rogue" pharmacies, are also motivated by "a business interest" in opposing all medication importation into the U.S. "Often the rationale is protecting the drug companies and U.S. pharmacies because the prices on drugs are lower in other countries," he said.
Levitt said he expects higher demand by Americans for international pharmacy medications with the rollout of Obamacare insurance plans this year, which will enable many more people than before to visit a private doctor, and get prescriptions.
Some of those people, he said "are going to go to the pharmacy and they're going to find out the copay is beyond their reach, the drug isn't in the formulary," or list of medications covered by their Obamacare plans. Those people, faced with high costs of medications in the U.S., are potential customers of international pharmacies, he said.
Levitt noted there is not a similar company or agency "set up to check the legitimacy of drugs" being sold from non-U.S. pharmacies.
But Roger Bate, an economist who focuses on counterfeit and substandard medicines, recently did an analysis that tested five brand-name drugs—Lipitor, Viagra, Celebrex, Nexium and Zoloft—purchased from online pharmacies.
The analysis found that all of those drugs were authentic when they were purchased from eight pharmacies certified by the NABP and Legitscript.com, both of which do not certify international sites that ship to the U.S. in violation of the law.
But Bate's analysis for the National Bureau of Economic Research also found that all of those drugs were authentic when purchased from 22 pharmacies—overwhelmingly foreign—that are accredited by PharmacyChecker.com and the Canadian International Pharmacy Association.
And out of 49 sites that are not accredited by any of the four groups, all of the drugs were authentic, except for eight samples of Viagra, according to Bate's analysis.
"Even with the noncredentialed sites, we still only got fake Viagra," Bate told CNBC.
His analysis noted, "While these findings confirm the Food and Drug Administration warning against rogue websites, they do suggest that a blanket ban against all foreign websites may deny consumers substantial savings from" sites that are certified by PharmacyChecker or the Canadian International Pharmacy Association.
While the sample size of the study was too small to draw conclusions about the entire online pharmacy market, Bate said the findings suggest that even if a person buys from a nonaccredited overseas pharmacy there is a good chance they are going to get legitimate medication.
He also noted that there is a strong disincentive for an online pharmacy that wants remain in business to sell counterfeit product.
"You want repeat customers, so you want to sell legitimate pharmaceuticals," noted Bate.
He did, however, acknowledge the risk of a pharmacy starting off by selling customers name-brand versions of drugs and then switching to generic versions to save money, without informing the customer.
—By CNBC's Dan Mangan.