Over the past two years, Oakland police refused to certify the applications of nearly 300 immigrants who needed the department to confirm they were crime victims so that they could qualify for special visas to remain in the United States.

Officials said this week they realized that some of those denials may have violated a state law that requires local police departments to certify the visa applications of victims who cooperate during investigations or criminal prosecutions. They have begun an internal audit to see which cases may have been rejected in error and are asking immigrants who were rejected to re-apply for the so-called U visa.

Police officials said they did not certify some because the applicants used an outdated form or had criminal histories, among other reasons.

“We had not been fully and squarely within the law,” said Oakland Police Chief Anne Kirkpatrick. “We want our community to know that they can come back to us.”

The revelation came last week, when attorneys in the Alameda County public defender’s office told the Police Department it wasn’t complying with the state’s Immigrant Victims of Crime Equity Act in two cases involving its clients. The law, which went into effect in January 2016, lowered the threshold for who’s considered a “helpful” victim, sped up the deadline for police certification and took away some previous discretion law enforcement agencies had in approving applications.

“Many of our clients are on both sides. They were arrested on suspicion of some crimes, and they were victims of some crimes,” said Public Defender Brendon Woods. “We want to create an environment where, whether you’re a citizen or a noncitizen, you can still go to the police department and report crimes and be helpful.”

U.S. Citizenship and Immigration Services gives the visas to 10,000 immigrants each year who were physically or mentally abused and helpful to law enforcement during an investigation or prosecution. Having the visa allows a person to live and work in the country legally for four years and apply for a green card. While the federal government administers the program, it requires certification by local law enforcement.

The same year the new California rules took effect, Lt. Jill Encinias of the Oakland Police Department’s special victims section began reviewing applications more carefully and checking whether the subjects were themselves suspects in other crimes. The effect: an average rejection rate of less than 2 percent suddenly jumped to 15 percent in 2016 and 2017.

Oakland police officials said they weren’t aware of the new state law until the public defender’s office pointed it out to them.

“We have a moral responsibility to the citizens of Oakland and the United States to make sure that they’re protected, so that’s one of the reasons why we would check,” Encinias said. “Does it bother us that we have to say a person is helpful for this particular case when they’re being looked at for domestic violence? ... Yes, it does. But now that we know we have no choice, that’s what we’re going to do.”

In the two cases the public defender’s office brought forward, the men had been arrested on suspicion of domestic violence, Encinias said.

Raha Jorjani, director of the public defender’s office’s immigration representation unit, said she couldn’t discuss either case. But she said it wasn’t Oakland’s job to pick and choose applicant approvals based on criminal accusations. That’s for the federal government to determine, she said, and when a police department rejects someone, that person has little recourse.

“State law requires that if someone cooperated, a certification be signed,” she said. “Many of our clients are victims of crime who cooperate. They, too, should have an opportunity to apply and be considered.”

Susan Bowyer, an attorney at Oakland’s Immigration Center for Women and Children, pointed out one of her clients who was rejected by Oakland police for certification but whom she believes should have received the approval. The client’s abusive ex-boyfriend had come to her house, apparently high on drugs, threatening to kill her, and trying to force his way through the door.

Later, after another similar incident, the woman, Maria Valencia, applied for U visa certification, but Oakland police rejected her application on the grounds that she was the victim of a domestic violence restraining order violation — not domestic violence itself — according to Bowyer, who said that was an incorrect legal interpretation.

On Wednesday, after the Police Department said it would reconsider petitions, Bowyer’s office sent a letter asking for Valencia’s application to be approved.

Even with the extra scrutiny, Oakland officials say they typically certify more applications per capita than any other city in the country. Oakland is second to only Los Angeles, with nearly 10 times its population, in terms of how many get certified annually.

A preliminary review Wednesday by Encinias found that of the 144 immigrants who were rejected last year: 25 were denied on the grounds of criminal or gang activity, 63 because the crime committed against them didn’t qualify, 37 because they refused to assist in an investigation and 19 because their applicant information or form was incorrect.

Of the last category, 16 were corrected and approved. Encinias said the department will review the 25 applicants suspected of crimes to see if they were cooperative victims in other qualifying cases.

Despite a sizable federal backlog and waiting list to get a U visa, which can take in some cases 15 years, it’s still worth applying, Bowyer said. Unlike the Deferred Action for Childhood Arrivals recipients — whose personal information is retained by the federal government — U visa applicants can keep their home addresses confidential, so the risks are substantially lower, she said.

“People think it’s better to have something than nothing,” Bowyer said.

Officer Johnna Watson, an Oakland police spokeswoman, said immigrants who are victims or witnesses should feel comfortable reporting crimes.

“If we’re saying that we’re an accepting city and we’re a diverse city and we’re a sanctuary city,” she said, “under that umbrella of a sanctuary city, everyone then has a right to be protected and to be safe and to ensure that there’s a process that is there if someone becomes a victim.”

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