Two gay US soldiers who chained themselves to the White House fence in protest over the military’s gay ban have had the charges against them dropped.

Lt Dan Choi and Capt Jim Pietrangelo pulled the stunt with four other protesters in April. They opted to go to trial to answer two charges each of failing to obey a lawful order, while the other four protesters accepted a fine.

They were due to face the charges in court on Wednesday but the Justice Department prosecutor dropped them, saying they had not broken the law.

According to reports, the Washington DC’s attorney-general’s office said that the charges of failing to obey a lawful order mean it is an offence to remain on a street after being told by a police officer to move on.

After examining footage of the incident, officials decided that the pair had not broken the law because they were standing on a ledge when they chained themselves to the fence.

Mayor Adrian Fenty’s communications director Mafara Hobson told Metro: “While chained to the fence, the defendant [meaning both Choi and Pietrangelo] was standing on a ledge – not – the sidewalk. As such, he was not blocking pedestrian traffic.

“Once that was realised, the focus of the investigation shifted to what happened immediately prior to his handcuffing himself (ie, was he blocking the sidewalk at that time and did an officer ask him to move on).

“After interviewing law enforcement, it was determined that the defendant had not been asked to move on at that point. Therefore, he could not be prosecuted for any activity prior to the handcuffing either.”

Writing on his Twitter account, Lt Choi said: “Victory for truth today! Government drops case against us.”

In an interview with US gay news source Advocate, he attacked President Barack Obama for “failing” to lead on civil rights.

Lt Choi said: “It’s demoralising – Obama failing in leading on civil rights. It’s not like there’s so much on his plate; we know that’s a cop-out. [The administration] is incompetent with dealing with civil rights, and that is the most frustrating.”

President Obama promised he would repeal the law in his 2008 election campaign.

Under the current law, gay and lesbian soldiers must keep their sexual orientation secret. They can be fired if they, or someone else, reveals it.

A review is underway and expected to end in December, while troops are being surveyed on their views towards lifting the ban.