A judge made several errors when he threw out video evidence allegedly showing New England Patriots owner Robert Kraft twice paying for sex at a South Florida massage parlor, prosecutors argued in a court papers to keep alive their case against one of the NFL's most prominent personalities.

The state attorney general's office filed its argument with the Fourth District Court of Appeal late Tuesday, just before a deadline that otherwise likely would have meant the dismissal of Kraft's second-degree misdemeanor charge. It said Palm Beach County Court Judge Leonard Hanser made several errors in his May ruling and argued that even if he didn't, he went too far by suppressing the recordings police secretly made in January at the Orchids of Asia Day Spa.

They said Hanser erred when he ruled Jupiter police detectives and the judge who issued the warrant allowing the secret installation of cameras at the spa did not do enough to minimize the invasion of privacy of customers who received legal massages. They said even if justices agree with Hanser that more should have been done to protect the innocent, it shouldn't protect Kraft, whom they say clearly paid for sex.

They also argued that even if the warrant was faulty, the detectives executed it in good faith, which courts have ruled is usually sufficient for evidence to be used in court, because doing otherwise allows criminal activity to go unpunished.

The prosecutors said Jupiter police detectives lawfully obtained the warrant allowing them to secretly install cameras in the spa's massage rooms and lobby, after spending days observing almost exclusively men entering the spa, obtaining trash that showed sex occurred there and interviewing customers after they left who admitted paying for sex.

During the five days of recording, prosecutors said 25 customers clearly paid for sex, 10 likely did but could not be proven because of poor lighting and four did not. Kraft was one of 25 men charged and some have accepted plea bargains. The owner and some employees are charged with felonies, with those cases also stalled because of similar rulings tossing the videos that are under appeal.

"That the spa was regularly used as a brothel is confirmed by the small percentage of recorded massages that ultimately appeared lawful," state Deputy Solicitor General Jeffrey DeSousa wrote.

If the appeal fails, prosecutors will likely have to drop their case against Kraft, a widower worth $6 billion whose Palm Beach mansion is across a bridge from the spa.

Kraft, 78, pleaded not guilty but issued a written apology in March, acknowledging he disappointed many people "who rightfully hold me to a higher standard." A spokesman for his attorneys did not immediately respond to a phone call and email Wednesday seeking comment.

According to police records, Kraft was chauffeured to the spa on the evening of Jan. 19, where officers secretly recorded him engaging in a sex act with two women and then handing over an undetermined amount of cash. Investigators said Kraft returned 17 hours later and was again videotaped engaging in sex acts with a woman before paying with a $100 bill and another bill, police said.

Only hours after that, Kraft was in Kansas City for the AFC Championship game, where his Patriots defeated the Chiefs. His team then won the Super Bowl in Atlanta, the Patriots' sixth NFL championship under his ownership.

The NFL has issued no sanctions against Kraft, but has said it is monitoring the case.

Hanser in his ruling said the judge who issued the warrant failed to give Jupiter detectives explicit instructions on how to monitor the video feed, allowing them to invade the privacy of legitimate customers.

"The fact that some totally innocent women and men had their entire lawful time spent in a massage room fully recorded and viewed intermittently by a detective-monitor is unacceptable," Hanser wrote.

While prosecutors are arguing that ruling is faulty on several fronts, they focused on whether the recordings illegally violated Kraft's privacy.

First, they said Kraft had less of an expectation of privacy when he went to a public business to engage in an illegal activity.

Also, there was no way for detectives to know if a massage was illegal until it was over, so viewing someone disrobing and naked was allowed under the warrant, DeSousa wrote. He disputed defense arguments that the detectives should have only viewed the first five minutes of video showing each customer before switching off the feed, and then turning it on again only periodically to check for evidence of a crime.

If "viewing the first five minutes of a massage was acceptable, it is hard to conceive why viewing the rest of the massage should be deemed constitutionally impermissible — particularly when the evidence sought to be obtained was the so-called 'happy ending' that, by definition, takes place at the conclusion," DeSousa wrote.

The appeals court has not scheduled oral arguments. No matter which way the justices rule, the losing side will likely appeal to the Florida Supreme Court.

Terry Spencer reports for the Associated Press.