MORGAN HILL — A judge took the unusual step Friday of reinstating bail for former San Francisco 49ers star Dana Stubblefield after his attorneys argued that the woman who accused him of raping her at gunpoint lied under oath when she denied ever working in the porn industry or receiving money for sex.

Superior Court Judge Jacqueline Duong set bail at $500,000 bail and ordered Stubblefield to wear an electronic monitoring device after defense lawyers Ken Rosenfeld and Allen Sawyer discovered a 15-second video of the woman dancing in the nude, available to paying customers on a porn website. The 34-year-old woman, who the prosecution says is intellectually disabled, had testified during the preliminary hearing last month that Stubblefield forced her to have sex with him nearly three years ago when she went to his Morgan Hill home seeking babysitting work.

But Stubblefield claimed he paid the woman to have sex with him.

The judge denied prosecutor Tim McInerny’s request to set bail at $1 million, noting that the defense had pointed out that Stubblefield was unlikely to flee because he has strong ties to the area and two children, and had made all his previous court appearances. Because the judge had sealed the case earlier this month and imposed a gag order on the prosecutor and defense attorneys, it was unclear Friday exactly what other factors Duong may have considered besides the video before taking the unusual step of reversing Judge Paul R. Bernal’s no-bail ruling.

Before the case was sealed, Stubblefield’s lawyers argued that the woman’s “commercial sexual activity’’ was legally relevant because it corroborated their client’s claim that he paid her for consensual sex during the April 9, 2015, encounter. They also contended it cast doubt on her veracity, particularly since she has given what Bernal called “varied’’ testimony on the question of whether he threatened her with a gun — including that it could have been a cellphone.

Prosecutor Tim McInerny had called Stubblefield’s bail motion a clumsy attempt at “victim-shaming.’’ Normally, a victim’s sexual history is not allowed in a rape trial.

“These guys are violating the rules of professional conduct,’’ McInerny said before the judge barred the public from reading the briefs on the issue.

Last month, Stubblefield was led away from Santa Clara County Superior court in handcuffs after Bernal found there was probable cause to hold him over for trial. He had been free on $250,000 bail for more than a year. But it became a no-bail case after the prosecution added the allegation that Stubblefield used a gun during the assault on the woman.

Stubblefield faces at least 15 years to life in prison if he is convicted of forcible rape, forcible oral copulation, rape and oral copulation of a person incapable of consent, and false imprisonment, with the gun enhancement. A trial is tentatively scheduled to begin in March.

A central issue at trial will be whether the woman was capable of consenting to sex with Stubblefield, even if the jury believes she did consent. Stubblefield’s lawyers argue in their motion that the woman’s ability to allegedly post a nude video is one of several signs she was able to decide whether or not to have sex with Stubblefield.