But when she tried to get the medication from her local Walgreens on Thursday, the pharmacist asked whether she was pregnant. When she said she was, he refused to give her the misoprostol, citing “his ethical beliefs,” she recalled in a detailed account on Facebook.

Ms. Arteaga described her response in the post, which has been shared more than 30,000 times.

“I stood at the mercy of this pharmacist explaining my situation in front of my 7-year-old, and five customers standing behind only to be denied because of his ethical beliefs,” she wrote, adding, “I left Walgreens in tears, ashamed and feeling humiliated by a man who knows nothing of my struggles but feels it is his right to deny medication prescribed to me by my doctor.”

Walgreens said on Saturday that it had contacted Ms. Arteaga “and apologized for how the situation was handled,” but suggested that the employee had not run afoul of company policy by refusing to fill the prescription.

“To respect the sincerely held beliefs of our pharmacists while at the same time meeting the needs of our patients, our policy allows pharmacists to step away from filling a prescription for which they have a moral objection,” the company said in a statement.

In an update to her original post, which includes a photo of the pharmacist’s business card, Ms. Arteaga said her prescription was ultimately transferred to another Walgreens, where she was able to get the medication “with no problems.”