SACRAMENTO — California’s ban on displaying the Confederate flag doesn’t apply to individuals even if they are on government property, state officials said this week in settling a free speech lawsuit.

Fresno artist Timothy Desmond sued after his painting depicting the flag was barred from the 2015 Big Fresno Fair. His painting shows Confederate soldiers fighting in the 1864 siege of Atlanta, led by a soldier carrying the battle flag.

California’s 2014 law says the state cannot display or sell the Battle Flag of the Confederacy or any similar image unless it appears in a way that serves an educational or historical purpose. Fair officials used that law to ban Desmond’s painting a year later, but they let him display the painting during the 2016 fair.

The settlement signed by the state attorney general’s office on Monday says that the ban applies only to the state government and not to private individuals. Individuals are still free to carry, display or sell the flag on private or government property.

“The First Amendment is clear: the state may not ban the expression of certain points of view simply because some find them distasteful,” Center for Individual Rights President Terry Pell said in a statement Tuesday. “Freedom of speech has costs, whether in the form of hurt feelings of those who are forced to listen or the cost of police necessary to protect against the riots that sometimes result.”

The nonprofit Washington, D.C.-based center represented Desmond in the lawsuit.

California Attorney General Xavier Becerra’s office referred requests for comment to the state Department of Food and Agriculture, where the media office was not accepting messages after business hours.

Desmond himself wasn’t commenting on the lawsuit or the settlement, a spokeswoman for the center said. The center’s website describes him as a retired high school science teacher who regularly entered his paintings in local art fairs.

It says his relatives fought for the South during the Civil War, so he became interested in their lives and the battles in which they might have fought. He found that his great-grandfather’s brother may have fought in the battle for Atlanta.