Conservative groups at UC Berkeley can sue the school over the restrictions it placed on high-profile speakers after violent protests over the planned appearance of right-wing firebrand Milo Yiannopoulos, a federal judge has ruled.

U.S. District Judge Maxine Chesney of Oakland on Wednesday upheld the university’s contention that it was motivated by security, not liberal bias, when it scheduled talks by other conservative luminaries in smaller and more remote campus locations than the speakers preferred. But Chesney said the Berkeley College Republicans and Young America’s Foundation could proceed with their suit over university standards for “high-profile” speakers, imposed after the Yiannopoulos protests and over alleged discrimination in security fees.

Yiannopoulos’ February 2017 speech was canceled after a student demonstration was taken over by masked protesters who smashed windows and set fires. He then spoke for a few minutes on campus in September in an event that conservatives had promoted as “free speech week.”

The conservative groups said two more planned speakers, writer David Horowitz and author and television commentator Ann Coulter, had to cancel their appearances last year because university officials rescheduled their evening talks to daytime hours at buildings far from the center of campus. Radio host Ben Shapiro, supported by the same groups, spoke at UC Berkeley in September after paying a security fee that was challenged in the suit.

The suit alleged that the university adopted an unwritten “high-profile speaker policy” in March 2017 that allowed officials to effectively censor conservative speakers by choosing the time and place of their appearance. The school contends it is entitled to determine the need for security measures, but Chesney said the conservative groups can try to prove that the policy gives officials too much leeway to restrict free expression.

The policy, as described in the lawsuit, contains “no standard for determining what events fall under the policy, at what locations events may be held, and what, if any, security fee may be imposed,” the judge said.

She rejected claims that the university discriminated by allowing former Mexican President Vicente Fox and Maria Echaveste, a former aide to President Bill Clinton, to speak at better locations and more convenient times than the conservatives. Neither of them posed the security concerns that school officials cited for Yiannopoulos and like-minded speakers, and “there are no allegations suggesting those concerns were unfounded,” Chesney said.

But she refused to dismiss a claim of discrimination based on a $9,162 security fee for Shapiro’s talk, compared with a $5,000 fee for a 2011 speech by Supreme Court Justice Sonia Sotomayor. The two spoke at the same location, and Sotomayor may have had a larger audience because the balcony was closed for Shapiro’s appearance, Chesney said.

Harmeet Dhillon, a lawyer for the conservative groups, said she was generally pleased with the ruling. “It means the case will go forward,” she said.

But UC Berkeley spokesman Dan Mogulof said the ruling had upheld the campus’ current policy on speakers and security, adopted publicly last year. He said the university could defend the security fee charged to Shapiro in light of the more than $800,000 the school spent on safety measures for the speech.

As for the allegations of an unwritten policy that gives officials unlimited authority to regulate speakers, Mogulof said, “The campus strongly denies that any such secret policy exists and it will continue to dispute any claims related to that issue.”

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter:@BobEgelko