The U.S. Supreme Court ruled Wednesday that Texas cannot be required to allow the Confederate flag on car license plates.

The case dealt with how much control state governments can exert over slogans and messages on vehicle license plates.

In the 5-4 ruling, the court said “just as Texas cannot require (Sons of Confederate Veterans) to convey ‘the state’s ideological message … (the Sons of Confederate Veterans) cannot force Texas to include a Confederate battle flag on its specialty license plates.”

The case came from Texas, where a state agency refused five years ago to approve a specialty plate requested by a group called the Sons of Confederate Veterans. The design was to include the group’s logo — a square confederate battle flag surrounded by the words, “Sons of Confederate Veterans 1896.”

RELATED: Supreme Court refines rules governing police conduct

After hearing public comments on the proposal, the state motor vehicle authority rejected the request, explaining that “many members of the general public find the design offensive,” and associate the flag “with organizations advocating expressions of hate.”

The Sons of Confederate Veterans sued, and a federal appeals court ruled that license plate messages, other than official mottos such as “Lone Star State,” are free speech and cannot be restricted by the state even if some residents consider the words offensive.

The federal courts have been divided on whether the message on a license plate is strictly government speech — in which case the government has more authority over what is said — or a mixture of government and private speech. Court battles have been fought over such messages as “Choose Life” on license plates.

In the Texas case, the appeals court said the legal test is whether a reasonable observer would understand the message to be an expression of government or private speech.

Texas Gov. Greg Abbott filed court papers as state attorney general urging the court to rule in favor of the state and against the confederate group.

The court’s liberals were largely united in ruling that Texas cannot be required to allow the Confederate flag on car license plates. The fifth vote was Justice Clarence Thomas, the court’s only African American.

This article originally appeared on NBCNews.com.