The sexual assault case against Kevin Spacey has been dropped, according to Massachusetts prosecutors.

The decision was made “due to the unavailability of the complaining witness,” said Cape and Islands District Attorney Michael O’Keefe in a document filed Wednesday.

Spacey, 59, had been accused of groping an 18-year-old man in July 2016.

The former busboy refused to speak in court earlier this month — invoking the Fifth Amendment after being questioned by the “House of Cards” star’s lawyer about text and Snapchat messages that could prove the actor’s innocence.

He initially denied deleting the messages, which — according to Spacey’s attorney Alan Jackson — could possibly prove he consented.

“This entire case is completely compromised,” Jackson said in court. “This case needs to be dismissed and I believe it should be dismissed today.”

A hearing had been set for July 31 before prosecutors decided to drop the case Wednesday.

O’Keefe’s office said they had met with Spacey’s accuser on Sunday “to further review” the charges “in light of” him taking the Fifth.

“The complaining witness was informed that if he chose to continue to invoke his Fifth Amendment right, the case would not be able to go forward,” prosecutors explained in a press release.

“After a further period of reflection privately with his lawyer, the complaining witness elected not to waive his right under the Fifth Amendment. The complaining witness was further instructed that the only remaining avenue to continue the prosecution, since grants of immunity may not be made in district court, would be to indict [Spacey], immunize the complaining witness and force his testimony. This procedure has several infirmities. One, a defendant cannot be convicted on the uncorroborated testimony of an immunized witness. It is the second consideration that is more concerning. A grant of immunity compromises the witness toa degree which, in a case where the credibility of the witness is paramount, makes the further prosecution untenable. As a consequence, the Commonwealth has entered a nolle prosequi of the case.”

The family of Spacey’s accuser have also dropped its civil case against him “with prejudice,” meaning the matter cannot be revisited in court.

Their lawyer, Mitchell Garabedian, told reporters that the family made the move because of the “emotional roller coaster” they had been on. They’ve insisted that the case was not dropped due to a settlement.

“My client and his family have shown an enormous amount of courage under difficult circumstances,” Garabedian said in a statement Wednesday. I have no further comment at this time.”