California’s highest court Thursday unanimously ruled the public has a right to see emails and text messages about public affairs on government officials’ personal devices, ending a long legal battle that began in San Jose and setting a statewide precedent for records disclosure.

The ruling closes what government watchdogs said was a loophole that let public officials conduct the people’s business privately on personal phones and computers outside the reach of records requests that until now covered only their government-issued devices and accounts.

“We hold that when a city employee uses a personal account to communicate about the conduct of public business, the writings may be subject to disclosure under the California Public Records Act,” the court opinion said. “If public officials could evade the law simply by clicking into a different email account, or communicating through a personal device, sensitive information could routinely evade public scrutiny.”

Peter Scheer, former executive director of the First Amendment Coalition, called the ruling “a great thing for the public.”

“Government officials have been using this trick of communicating about public business on their personal email or text in order to avoid public scrutiny,” Scheer said. “It means the people we elect to represent us won’t be able to avoid public scrutiny by using personal email accounts — rather than government ones.”

After San Jose in 2009 refused to release personal emails and texts about a downtown development, one man waged a legal battle that went all the way to the California Supreme Court and led to Thursday’s 20-page ruling.

Ted Smith, a former lawyer with a background in nonprofit work, suspected that San Jose officials were using their private phones and email accounts to conceal dealings with former Mayor Tom McEnery, who proposed a development in downtown San Jose. McEnery received a $6 million loan from the city’s Redevelopment Agency.

In June 2009, Smith submitted a request to the city seeking public records involving specific officials related to downtown San Jose redevelopment. The city turned over everything — except Smith’s request for “any and all voicemails, emails or text messages sent or received on private electronic devices used by Mayor Chuck Reed or members of the City Council, or their staff, regarding any matters concerning the City of San Jose, including any matters concerning Tom McEnery.”

The city’s argument was simple: “What we’re saying is California’s Public Records Act doesn’t cover private emails,” said San Jose City Attorney Rick Doyle. A trial court sided with Smith, but in March 2014, an appellate court ruled in the city’s favor and Smith appealed to the state’s high court.

Although the San Pedro Square Market — McEnery’s project — is already built, Smith argued all communications about city business should be public, regardless of how they’re created, communicated or stored.

While San Jose owns more than 4,000 mobile phones for employees to use, government officials in smaller agencies across California often rely solely on personal devices for business. The court’s ruling applies to all public entities in California — from water districts to school districts to cities, counties and state agencies.

“This is an important victory for the public’s right to know,” Smith said. “Once again California is at the forefront of creating rules to guarantee that the public’s business is conducted with public scrutiny.”

Following the decision Thursday, Doyle said San Jose will need to craft policies to determine how it collects public records from private accounts. The court opinion only says a “reasonable effort” to search records must be made — but allows local agencies to decide how.

“We’re going to have to tread carefully on the issue of how we do a search for records on private devices,” Doyle said. “Is it enough to say ‘Check your devices and let us know,’ or will employees have to sign some kind of affidavit?”

After Smith filed suit in August 2009, the San Jose City Council adopted a policy to release elected officials’ communications from private devices, relying on “self-reporting” to get them. But Smith and his attorney, James McManis, said the rules should apply to city employees too.

“There was nothing sensitive about this information except that someone didn’t want to talk about what was going on at City Hall with respect to former Mayor Tom McEnery,” McManis said Thursday.

McEnery said “the public deserves full transparency” and that he had no quarrel with the ruling. He said dozens of other projects had received similar redevelopment loans but his got more scrutiny because “I was mayor for eight years and I picked up my share of enemies.”

McManis said the ruling also applies to city workers’ social media accounts because it focuses on the content of the communication — not the medium in which it occurred.

The ruling suggests cities can set policies to prohibit using personal devices for official business, but it also recognized that not all private writings by city workers are public. The communications “must relate in some substantive way to the conduct of the public’s business.”

“The court does acknowledge government workers’ right to privacy,” Doyle said. “If a city official writes a text to their spouse and says their co-worker is an idiot — that may not be a public record.”