An Oakland building inspector likely colluded with a property owner in 2016 to evict tenants from a building by improperly declaring it unsafe, according to internal documents released by the city, which described its employee’s behavior as “a violation of the public trust.”

The six tenants moved out of the West Oakland building in April that year and have been out since. The city rescinded the red tags two weeks after they were posted and told the property owner he should let the tenants return — even though the building, a commercial property that had been used as a live-work space, did not have city permits for residency.

The episode occurred months before the deadly Ghost Ship fire at an artists’ collective drew attention to the dangers of unpermitted residences and the city’s lax oversight of such properties.

The inspector, Thomas Espinosa, who worked in the city’s Planning and Building Department for 11 years, resigned in November 2016 after Oakland officials moved to fire him. His bosses said he abused his authority that spring when he red-tagged the building at 661 27th St. and ordered the tenants to leave, according to a copy of the city’s “notice of intent to terminate” letter.

Attorneys for Espinosa and property owner Patrick MacIntyre said the men did not collude to evict tenants. Espinosa’s attorney, Quynh Chen, said her client was simply doing his job and did nothing wrong — with one exception, which she called an honest mistake. She said city officials “dramatized” the facts in the case.

“There was no bad intent,” she said. “Basically there was a misunderstanding between Mr. Espinosa and his supervisors, and he took the bullet for it.”

MacIntyre’s attorney, David Sternfeld, said the tenants should not have been living in the building in the first place.

The Chronicle obtained the ex-inspector’s personnel file under a public records request. A federal grand jury and the FBI subpoenaed the city last fall to get Espinosa’s files, too. Spokesmen for the FBI and the U.S. attorney’s office in San Francisco said they had no public information to disclose, and declined to comment.

The records include the intent-to-terminate letter written by Darin Ranelletti, the department head at the time who now works as Mayor Libby Schaaf’s policy director for housing security. Ranelletti said in the letter that Espinosa jeopardized public trust with a series of inconsistent statements and questionable behavior.

His letter said the ex-inspector displayed a “documented pattern of abusing city resources and authority,” but that one incident in particular — the suspected collusion that culminated in an April 7, 2016, eviction — amounted to “serious misconduct.” The letter describes the incident in detail.

For years, court records show, MacIntyre, the owner of the building on 27th Street, had been trying to evict the tenants. A group of mostly artists, they had been living at the two-story building under a live-work lease initially signed by a previous owner before the property went into foreclosure and was bought by MacIntyre.

His building was once home to a French bakery, and wasn’t authorized to be used as a residence.

Espinosa said that as he drove to the office on April 6, 2016, he happened upon trash and graffiti outside the building, according to statements he gave to his supervisors and in court. Even though it was outside the district he was assigned to inspect, Espinosa stopped to take pictures. He said he saw construction going on through the open door.

Espinosa said he went back to the office and found that there were no permits for construction, so he posted a number of stop-work notices and scheduled an inspection for the next day. After the inspection, Espinosa said in the statement, he found safety hazards, including a lack of fire escapes, and red-tagged the building.

Espinosa should not have done that without first getting approval from a supervisor, Ranelletti said. When his bosses questioned him about his actions, Espinosa told them he had no prior contact with MacIntyre, according to Ranelletti’s termination letter.

But city officials reviewed his work phone records and found Espinosa had called MacIntyre’s cell phone three times two days before his purportedly impromptu inspection. And on that morning, April 6, between 5 and 7 a.m., Espinosa called MacIntyre twice, and MacIntyre called him once, according to Ranelletti’s letter and a phone log included in the personnel file reviewed by The Chronicle.

Chen said Espinosa was likely “drowning in paperwork” and forgot about the calls.

Two days later, Espinosa helped MacIntyre fill out a form that would have given him a permit to do work on the building, according to Ranelletti.

Later that year, Espinosa provided a declaration for MacIntyre to use in his litigation against the tenants in which he stated that he came across “voluminous amounts of marijuana” during his walk-through of the building. Yet city officials said that observation did not comport with his inspection records.

“If it was true that there was cannabis on site, then you should have reported that to your superiors and/or zoning investigator ... immediately after your inspection,” Ranelletti wrote. “You did not do either. You also provided no photographs to substantiate your claim.

“These facts strongly suggest collusion with the owner and that your inspection of the 27th Street building was outside the scope of your job as a city employee and quite possibly for personal gain,” he continued. “Had your actions gone undiscovered, you would have caused the indefinite displacement of multiple families.”

The six tenants were indefinitely displaced.

One of them — Christine Shepherd, 43, an artist who specializes in 19th century photographic processing — couch-surfed for a few months and ultimately moved to Oregon because she couldn’t afford Bay Area rents. She had lived at the West Oakland building for seven years and her boyfriend for more than a decade. She said it was safe.

“We had no idea that that was coming,” she said of the inspection and eviction. “It was like absolute panic. Your stomach just goes into a knot and you can’t think straight and you don’t know what your next step is going to be.”

Another tenant, Michael Taylor, 46, has been staying with friends and sleeping in his camper van ever since.

Despite Espinosa’s bosses ordering the red tags to be removed and the tenants to be allowed to move back in two weeks later, Kevin Greenquist, the tenants’ attorney, said MacIntyre did not do so and changed the locks.

Chen said the one mistake Espinosa made was delegating the removal of the red tag notices to MacIntyre, rather than doing it himself. Other than that, she said, he was doing what his position required. Chen said the city exaggerated its claims against her client so it wouldn’t be sued for wrongful termination.

Had there been collusion, the city would have provided documentation in the termination letter, Chen said.

“He should’ve just not done his job and stayed silent and not returned phone calls out of fear of favoritism,” she said. “If I worked for the city of Oakland and I wanted to show evidence of collusion I would attach financial records, actual evidence.”

She said Espinosa was not responsible for the evictions.

It’s unclear whether the 2016 case was an isolated event. The city Public Ethics Commission has an open investigation to determine whether Espinosa violated policies covering conflicts of interest, misuse of city resources, misuse of city position and more.

Oakland officials did not answer The Chronicle’s repeated questions about whether they investigated other cases to see if there was a pattern of improper interactions with other property owners and tenants.

City records show that officials became aware of the employee’s misconduct only after tenants and their attorney complained to Espinosa’s supervisors about his actions, prompting the internal review that led to the termination letter.

“I called the city of Oakland because I wanted to know, can they just make me homeless?” Shepherd said. “I guess I sort of trusted in city officials and democracy working for us.”

Greenquist said he was “outraged” that the city didn’t tell him that it found Espinosa likely colluded with the property owner. Greenquist said he was concerned there could be other similar cases.

“The city knew all this and didn’t say a word about it,” he said. “If you have a rogue inspector and find out all this stuff, why do you bury it when it could just be the tip of the iceberg?”

Greenquist continues to represent the tenants in their court fight with MacIntyre over whether the tenants were wrongfully evicted and what, if anything, they are owed.

The lawyer, who was with the tenants when the building was red-tagged, remembered Espinosa telling them they could be arrested if they returned to the premises. He said they had three hours to collect their belongings.

MacIntyre’s attorney, Sternfeld, said the tenants left on their own accord and should never have been living there in the first place. Sternfeld said the city’s finding of coordination between his client and the inspector was wrong.

“I can guarantee to you that my client did not collude with Mr. Espinosa,” he said.

Despite city officials concluding that Espinosa made false statements, the written declaration in which he testified about coming across hazards such as the cannabis grow continue to be used in the civil litigation.

Alameda County Superior Court Judge Scott Patton relied on that statement — which the city implied might contain falsehoods — in deciding a recent motion filed by the tenants.

Kimberly Veklerov is a San Francisco Chronicle staff writer. Email: kveklerov@sfchronicle.com Twitter: @kveklerov