SAN FRANCISCO — The public has a right to access emails and text messages about government business on the private phones and accounts of state and local officials and employees, the California Supreme Court ruled Thursday.

In a unanimous decision, the court said those communications were subject to disclosure under the California Public Records Act and not shielded because they were sent or received in personal accounts.

“If communications sent through personal accounts were categorically excluded from CPRA, government officials could hide their most sensitive, and potentially damning, discussions in such accounts,” Associate Justice Carol Corrigan wrote for the seven-member court.

The ruling came in a lawsuit against the city of San Jose. San Jose City Attorney Richard Doyle said he was not surprised by the decision and did not plan to challenge it.

But he said it raised practical challenges for cities and counties.

“The question is how do we access those communications on personal devices without the government being overly intrusive,” he said. “I don’t expect and intend to have people turn over their phones.”

The use of private email accounts by public officials has faced scrutiny in recent years, with accusations that some were using them as a way to avoid disclosure. Hillary Clinton was sharply criticized during the presidential campaign for using a private email account while at the State Department.

In a survey by The Associated Press two years ago, Gov. Jerry Brown, Lt. Gov. Gavin Newsom and other top elected officials in California acknowledged using personal email accounts to conduct government business.

Many states treat public business on private accounts as public records. And at the federal level, an appeals court ruled last year that work-related emails from a private account used by the White House’s top science adviser were subject to disclosure under federal open records laws.

Opponents have raised privacy concerns and said public officials sometimes need confidentiality to discuss unpopular views. They have also argued that sifting through employees’ private accounts and devices in response to requests for records would be expensive and burdensome.

“These are public officials, and the public does have some interest in knowing how they are conducting business,” said Jessica Levinson, who teaches privacy law at Loyola Law School in Los Angeles. “Having said that, the public doesn’t have the right to know everything that this person talks about.”

The lawsuit before the California Supreme Court was filed by Ted Smith, who in 2009 requested messages about development in downtown San Jose that were sent or received on private devices used by San Jose’s mayor and City Council. The city said it did not have access to any messages created on personal devices, so they were not public records.

Smith sued. A Superior Court judge ruled in his favor, but an appeals court overturned that decision in 2014.

“Openness in government is critical to a functioning democracy,” attorneys for Smith wrote in a brief to the California Supreme Court. “If the Court of Appeal’s decision in this case is allowed to stand, public employees can easily avoid accountability and subvert the intent of the (California Public Records Act) by hiding any communications that suggest corruption or the appearance of corruption in private accounts.”

San Jose countered that public employees retain privacy rights. Forcing them to turn over their passwords to inspect communications on private devices would be akin to making them hand over their house keys, the city said in a brief to the California Supreme Court.

“There is no indication that the (public records) act requires city councilmembers and employees to open their homes so that their personal diaries and correspondence could be inspected for presence of writings that mention the city of San Jose,” City Attorney Richard Doyle wrote. “Such an interpretation of the act would be unreasonable, and yet, it would be required if the Act was extended to writings at issue here.”