It varies from state to state:
California, New Jersey, Maine, Illinois, Massachusetts, Washington and Nevada all require pharmacies (and in CA, ME, MA and NV, each individual pharmacist) to fill any valid prescription someone presents. Pharmacists in those states indeed to not, as you wrote, have the freedom to refuse to fill prescriptions they don’t like.
Alabama, New York, Delaware, North Carolina, Oregon, Pennsylvania and Texas are slightly less “encumbering,” so to speak; they require pharmacies (or pharmacists, in applicable jurisdictions) unwilling to dispense medications to provide “a meaningful referral,” “timely access” or “no obstruction,” again, depending upon the jurisdiction.
Arkansas, Georgia, Mississippi and South Dakota are at the opposite end of the spectrum; they have, to varying degrees, regulations permitting pharmacies to refuse to dispense medications ranging from contraception to all drugs.
An informative chart, from which I took the above summary, is found here (PDF warning):
http://www.nwlc.org/pdf/PharmacyRefusalPoliciesJanuary2008.pdf
Note that the chart is published by the National Womens’ Law Center, but the actual legal cites check out.