Washington (CNN) The Supreme Court sided Tuesday with faith-based pregnancy centers in California in a case that pitted abortion rights against free speech.

The ruling was 5-4.

In the majority opinion, Justice Clarence Thomas wrote the law "unduly burdens protected speech."

The California Reproductive Freedom, Accountability, Comprehensive Care, and Transparency Act requires licensed clinics, which provide services like ultrasounds, to disseminate a notice stating that California has programs providing "immediate, free or low-cost access" to comprehensive family planning services including abortion.

The law also requires unlicensed clinics -- those that provide resources such as vitamins and diapers but have no medical providers on site -- to disseminate a notice that they are not licensed by the state. Religiously affiliated pregnancy centers say the law forces them to deliver a message that is both detrimental to their cause and in direct conflict with their mission to encourage childbirth.

Read More