After hearing about this case, there should be certain laws no one is allowed to break – even if they are a diplomat.

A United Nations diplomat was accused of raping one of his neighbors in Upper Manhattan over the weekend — but NYPD cops released him because he has diplomatic immunity, authorities said Monday.

Charles Dickens Imene Oliha, 46 — a career diplomat for the Ministry of Foreign Affairs and International Cooperation in South Sudan — was arrested in Sunday’s alleged sex assault on a woman inside her apartment around noon, according to a police report obtained by The Post.

Oliha was taken into custody on suspicion of rape and brought in for questioning, cops said.

But once he informed detectives from the NYPD’s Special Victims Unit that he was a diplomat, investigators confirmed he had immunity and swiftly released him without formally charging him, police said. 

The victim, who lives in the same building as Oliha, told cops she went to walk a neighbor’s dog around noon when a man approached her in the lobby, according to the police report and sources.

The man said he was going to follow the woman upstairs, to which she replied, “No, you’re not,” authorities said. 

But as the woman opened the door to her apartment, the suspect forced his way inside, police said.

The woman reported that the intruder pinned her against a wall and raped her using a condom before raping her again on the couch without a condom, police said.

The victim said she was in shock after the attack and went to sleep but later called 911 after a friend convinced her to make a report, cops said. 

She was taken to Columbia University Medical Center for medical attention. 

Oliha was arrested as a suspect nearly 12 hours after the alleged attack but was cut loose a short time later, police said. 

The alleged attack happened inside of a building on Wadsworth Terrace in Fort George where Oliha lives, police sources said.

“It’s incredibly disturbing that someone who is accused of rape cannot be held accountable no matter what the facts,” Jane Manning, director of the Women’s Equal Justice project and a former sex-crimes prosecutor, told The Post.

“I hope that the NYPD detectives will still do a full and thorough investigation to establish what the evidence shows.”

Oliha could not be reached for comment.

On Monday afternoon, two detectives were spotted leaving the apartment building, and another pair of cops was posted in the lobby. Residents said the officers’ presence was not typical.

Two women answered Oliha’s door and declined to comment when asked about the incident.

“There’s no one here to talk about that,” one of the women said.

The deputy permanent representative for the embassy of South Sudan, Cecilia Adeng, told The Post on Monday, “We aren’t aware of this.

“I tried calling him just now before I called you, but he didn’t answer,” she said of Oliha.

She said her boss is currently away from the office and that the embassy would have more comment when he returns.

“He’s going to be coming in. So I will have a conversation with him and then get back to you,” she said of the higher-up.

“And of course this is not something that’s tolerable at all,” she added of the allegations. “So we’ll be reporting to our headquarters and seeing what’s going on.”

In another case involving diplomatic immunity, Martiniano Sosa — the husband of an Argentine diplomat — was allowed to walk free after allegedly beating a United Nations worker to a pulp, police sources said. 

Sosa allegedly doused Mutaz Hyssat with a drink and slugged him in the face during a 2018 boozy party at the Cuban Embassy in Midtown.

Sosa was covered under the diplomatic immunity of his wife, Argentine envoy Natalia Babio, and did not face criminal charges, sources said. It’s not clear if Sosa ever faced any repercussions for the incident or spoke about it publicly.

The alleged beatdown came a week after another case in which a suspect was briefly freed thanks to his wife’s credentials.

In that case, exclusively reported by The Post, a British diplomat was allegedly beaten up by her husband when he became enraged at the clothes she wore.

Cops were forced to let the alleged attacker, Youssef Amrouche, go because he was protected by his wife’s diplomatic immunity. He then had his diplomatic protection rescinded by his country in a rare move and was arrested over the incident.

In January 2019, Amrouche pled guilty to attempted misdemeanor assault and agreed to complete a batterer’s program in exchange for no jail time.

Separately, in 2017, Sehon Marshall, 43, who serves as a counselor for the Permanent Mission of St. Vincent and the Grenadines, allegedly punched his wife, Sandra Marshall, 36, in the face after a fight broke out at their Canarsie home, according to police sources.

While officers couldn’t bust Marshall because of his immunity, he later lost his job over the incident, the country’s prime minister said previously.

The notion of diplomatic immunity has its roots in ancient Greek and Roman times, when it was doled out as a special status to envoys, according to the US State Department.

The US adopted its own legislation in 1790 that gave “absolute immunity’’ to diplomats and their families and servants. The law has since been revised over the years to decrease the amount of immunity at times and the number of people who might get it.

“The United States benefits greatly from the concept as it protects U.S. diplomats assigned to countries with judicial systems far different than our own,’’ the agency says.

Still, the department acknowledges that “dealing with the concept of immunity poses particular problems for law enforcement officers who, by virtue of their oath and training, are unaccustomed to granting special privileges or concessions to individuals who break the law.”

The State Department adds that law enforcement must keep a sharp eye on how it is administered, saying, “Diplomatic immunity is not intended to serve as a license for persons to flout the law and purposely avoid liability for their actions.”