An Arizona woman says she felt ashamed and humiliated after a pharmacist, citing moral objections, refused to dispense a pregnancy-terminating drug that was prescribed for her after she learned she was about to miscarry.

Nicole Arteaga, 35, of Peoria, said the encounter happened last Thursday at a local Walgreens. Her Facebook post about it has gone viral, with more than 36,000 shares and 16,000 comments as of Monday afternoon.

Arteaga said she and her husband have a 7-year-old son and have wanted another child. After a miscarriage several years ago, the couple were thrilled to find out a couple of months ago that Arteaga was pregnant again.

The excitement turned to heartbreak last week, when Arteaga, whose pregnancy was being closely monitored, went in for a 10th-week ultrasound. Her doctor told her that the fetus had stopped developing and had no heartbeat, so she was going to have another miscarriage.

The doctor gave her two options to manage the miscarriage, she said: She could have a surgical procedure, or she could take medication.

Arteaga decided to get the prescription. On Thursday evening, she and her son picked up some photos from the drugstore and then headed to the pharmacy for her medication, she said.

"I thought it was going to be regular: running and getting what I need, and we're going to be out of there," Arteaga told NBC News. "It didn't turn out that way. I was very shocked and couldn't believe what was happening."

Arteaga said the pharmacist asked her whether she was pregnant and then informed her that he wouldn't be giving her the medication. When Arteaga asked why, he replied that it was because of his "ethics," she said.

The only thing I could process in that moment was I didn't have control over my baby not being able to live inside of me, and I don't have control over how to miscarry."

"I felt so helpless, and I felt so out of control of my own body. The only thing I could process in that moment was I didn't have control over my baby not being able to live inside of me, and I don't have control over how to miscarry," she said.

Confused, Arteaga thought that if she explained what was going on, the pharmacist would change his mind. With her 7-year-old son beside her and a long line of customers waiting, Arteaga said she tried to discreetly tell the pharmacist that "the doctor prescribed it because the baby is not developing and the baby's not alive."

But the pharmacist still said no, she said. Finally, he offered to transfer the prescription to another pharmacy. Arteaga eventually picked it up at another Walgreens in Peoria the next day.

Walgreens confirmed the incident to NBC News and said in a statement that it has a policy that allows pharmacists to step away from filling a prescription for which they have a moral objection.

But it said: "It's important to note in that situation, the pharmacist also is required to refer the prescription to another pharmacist or manager on duty to meet the patient's needs in a timely manner."

Walgreens said the policy applies to all of its pharmacies across the country. But state laws on pharmacies vary: Six states, including Arizona, have laws or regulations that allow pharmacists to refuse to dispense medication for religious or moral reasons, according to the National Women's Law Center.

Eight other states explicitly require pharmacists to provide medication to patients even if there are objections, and seven others allow pharmacists to refuse but prohibit them from obstructing access to the medication, the National Women's Law Center says.

Arteaga said she has no problem with the pharmacist's having beliefs different from hers, but she said she wished that one of the two other pharmacists working behind the counter could have dispensed her medication instead of making her go to another pharmacy.

"I could have just, right now, been dealing with me and my family and the loss of our baby," she said.

Walgreens said it would be providing additional training to all of its pharmacists on how to appropriately handle such situations. The company also said that it reached out to Arteaga, but she said the only contact she has had with Walgreens since the incident was when she spoke to the store's manager the following day to complain. The manager said she would look into it but never got back to her, Arteaga said.

Since Arteaga shared her story, other women who have had similar experiences have reached out, she said.

"They're thanking me for being a voice and standing up, and that is so empowering," she said.