SAN JOSE — In an astounding outcome to a controversial case, a jury Wednesday failed to reach a verdict in the trial of a former San Jose police officer charged with raping an illegal immigrant while on duty.

The jury deliberated less than two full days before deadlocking 9-3 in favor of acquittal, a surprising turn given the ferocity of the prosecution of former officer Geoffrey Graves, 40, who was fired in September, about two years after the revelations surfaced. Graves, who initially lied about having sex with the woman and then claimed it was consensual, had offered in March to plead guilty to one count of rape to avoid being convicted of enhancements that could have landed him in prison for life. But the Santa Clara County District Attorney’s Office refused the offer, gambling on a conviction.

It was not immediately clear Wednesday whether the district attorney’s office will decide to seek a retrial. The office said it is reviewing the case but otherwise had no comment.

Wednesday’s mistrial in a 2013 case, which strained the already shaky trust between immigrant communities and local law enforcement, was a blow to prosecutors in the biggest case District Attorney Jeff Rosen has filed against a cop since he took office five years ago.

Had Graves been convicted of rape, the former cop would have faced a maximum of eight years in prison, but a life sentence if the panel had also found him guilty of the additional allegation that he unlawfully entered the woman’s hotel room with the intent to commit sexual assault. Another enhancement — that he was armed with a gun during the sexual assault — could have made him ineligible for parole for more than 50 years, but was dismissed last year by a judge after the preliminary hearing.

“Is there really any such thing as consensual sex when an officer is on duty and carrying a gun and wearing a bulletproof vest?” said San Jose’s former independent police auditor, LaDoris Cordell. “This case raises that question, particularly when he acted under the color of authority with an undocumented woman.”

Court observers attributed Wednesday’s outcome to the vigorous defense presented by Deputy Alternate Public Defender Kristin Carter, who eviscerated the credibility of the alleged victim in her closing argument last week and insisted the sex was consensual.

Graves, who has been held without bail since March, is likely to remain in jail until at least next week. Carter, who declined to comment Wednesday, is expected to seek bail based on the favorable split while Rosen decides whether to retry the case.

If Graves insists on his constitutional right to a trial within 60 days, the prosecution would have until the 59th day to proceed with a new trial or not. If there is a retrial, it could be overseen by Judge Ron M. Del Pozzo, who presided over the trial, or sent out to another judge. Earlier this year, the case against Graves became even harder when Del Pozzo, citing concerns about a fair trial, ruled that jurors could not hear about separate allegations that Graves used to shove around his ex-girlfriend.

Graves, who was fired in September, was among a team of four cops who responded to a disturbance call in the middle of the night on Sept. 22, 2013, at an apartment where a woman was in a drunken argument with her husband.

No crime occurred, but the woman asked to be taken to the Marriott TownePlace Suites hotel, where she had worked as a maid. Graves and another officer escorted her there. Three weeks later, she reported to police that Graves came to the room and raped her, saying she was initially afraid to report it because she was in the country illegally, and also was afraid her husband would reject her and police would retaliate.

Deputy District Attorney Carlos Vega, a former Torrance police officer himself, argued that Graves “took advantage” of a “perfect victim” — an illegal immigrant who was drunk and spoke little English — and “raped one of the most vulnerable people in our society.”

Graves first denied during interviews with investigators that he had sex with the woman, but testified during his trial that he lied repeatedly until after he learned that her DNA was found on his bulletproof vest because he was afraid of being fired. Graves also told jurors that he could tell during the three minutes he was alone with the woman while he drove her to the hotel that she wanted a tryst with him: “I remember thinking, she really liked me and was totally coming on to me.”

Carter contended that the woman had ample reason to twist what was a consensual, extramarital one-night stand into a purported rape, including to avoid the DUI arrest, obtain a visa to stay in the country and win a monetary settlement from the civil lawsuit she filed against the police department. And she said the woman had asked the California Highway Patrol officers who stopped her to drive her to the same hotel where she had supposedly been raped, something a “real victim” would not do.

“My client may be a dog,” Carter told the jury last week, “but he is not a monster.”

Contact Tracey Kaplan at 408-278-3482. Follow her at Twitter.com/tkaplanreport.