BEIJING — For more than 1,200 days, the Chinese government sought to build a case against Wang Quanzhang as it held him incommunicado in secret jails, denying him visits from his family and the lawyers he requested.

On the day of his trial, Wang struck back: He denied the government a quick verdict.

A Chinese court in the city of Tianjin said Wednesday that it held a hearing behind closed doors for Wang, one of the country’s prominent civil rights lawyers, but could not immediately reveal the outcome because “state secrets were involved.”

The real reason for the hiccup, Wang’s supporters say, was more embarrassing for authorities: Wang fired his government-appointed lawyer soon after his trial began, throwing a wrench into what were supposed to be swift and scripted proceedings.

Four years after President Xi Jinping exhorted the Communist Party to strengthen the rule of law, international observers say the persecution of legal professionals like Wang shows the party-state moving in the other direction. In October, the United Nations Human Rights Council criticized Wang’s detention and called for his release.

The story of his unusual day in court illustrates how the Communist Party uses layers of secrecy and a pliant court system to enforce its will — and how one individual, despite spending three years inside the state security apparatus, mounted a fleeting moment of resistance.

Firing his lawyer “was his way to show defiance” and “not let the Chinese Communist Party have its way,” said Swedish human rights activist Peter Dahlin, a longtime friend and collaborator of Wang’s. “The government tried to make this happen with minimal attention from diplomatic missions and the media,” he added. “Obviously, this backfired spectacularly.”

Wang, 42, attracted Beijing’s ire by helping train and fund a grass-roots network of legal advocates with Dahlin in 2009 to organize lawsuits and protests to fight land grabs and police brutality. He was rounded up as part of what became known as the “7-09 crackdown,” when the government on July 9, 2015, seized more than 200 lawyers and activists in an unprecedented countrywide sweep to break up the movement.

For months, Wang disappeared into what is known as a black jail. When police notified Li Wenzu, his wife, that he was being held for serious crimes, they would not disclose his location or details of his condition, citing national security.

Since his arrest, seven defense lawyers appointed by the family — as well as Li herself — have been denied visiting rights, she said. This summer, the authorities chose a lawyer to represent Wang.

“My husband was always an innocent man,” Li said. “They violated the law for so long, by illegally arresting him, by illegally detaining him for three and a half years, by illegally denying him lawyers, that now they’re scared to have even an open court because it would expose the truth — that this is all illegal. That’s why they choose this excuse that the case touches national security.”

Arguing that the legal defense network was fanning popular unrest to destabilize the government, China systematically tried and sentenced more than a half-dozen of Wang’s peers and associates to five to eight years on subversion-related charges.

In show trials made for television, some defendants read from scripts.

Other prosecutions turned on confessional interviews taped for the state broadcaster China Central Television.

Dahlin was detained in early 2016 and released and deported after being forced to film a confession for CCTV.

That playbook did not work on Wang, the last holdout of the “7-09” detainees. To the outside world, at least, he did not provide any indication that he was ready to cooperate with prosecutors, and starting from dawn on Wednesday, neither did his supporters.

At 5 a.m., in a confrontation witnessed by reporters, a dozen plainclothes security agents blocked Li as she tried to leave her Beijing home to attend her husband’s trial in Tianjin, 80 miles away. 

By afternoon, authorities had blocked Western diplomats from attending the hearing and intercepted activists traveling from remote provinces to voice support for Wang. Outside the courthouse, security forces seized a demonstrator calling for free elections and Wang’s release and stuffed him into a black vehicle as foreign news cameras rolled.

By evening, word had emerged that a decision would be pushed back, without a clear signal that the trial had wrapped up. In a text message seen by The Washington Post, Wang’s government-appointed lawyer, Liu Weiguo, told friends he did not know the hearing’s outcome because his client had dismissed him within the first minute of the trial. Liu could not be reached for comment.

“This was the most bizarre form of a show trial imaginable, where they couldn’t even put on a show,” said Jerome A. Cohen, an expert on Chinese law at New York University. Time and again, the authorities’ fixation on secrecy, Cohen said, showed “insecurity, not strength.”

Still, in a country where the government wins more than 99 percent of the time in court and failed prosecutions are unheard of in high-profile political cases, Wang will be made to pay. Few among his supporters expect that he can escape a heavy sentence, much less walk free.

Moreover, human rights groups say his resistance for three years behind bars may have taken an untold psychological and physical toll. And it may land him a harsher verdict in a court system in which a suspect’s attitude — submission or defiance — can outweigh guilt or innocence.

“Wang may not have bought into the ‘confessing in exchange for leniency’ tactic, and that’s why he has been detained for so long,” said Doriane Lau, a China researcher at Amnesty International.

Under Chinese law, suspects in political cases can be held at undisclosed locations for six months as state security officials gather evidence — or, as is often the case, extract a confession.

“In this case, we think there was a problem where prosecutors couldn’t get what they wanted,” Lau said. 

In the case of Wu Gan, a blogger associated with the lawyers’ movement, police detained his parents to force their son to confess in court or on camera. Wu refused and was tried on Dec. 25, 2017, in a closed courtroom, where he received an eight-year sentence.

Bärbel Kofler, the German government’s human rights commissioner, said in a statement that a fair trial for Wang was “impossible” given that he was denied a lawyer of his choosing. She called on the Chinese government to prosecute Wang in accordance with due process and open up the proceedings. “Unfortunately, the public has been denied access not only to this trial, but also to similar trials for quite some time,” she said.

Outside the murky justice system , Wang’s family has also borne the toll of his detention.

Since 2016, Li and the couple’s young son have been under constant surveillance, with state security at one point moving into an apartment in her building and, in another instance, driving her out of her rental home.

But Li and other wives of detained “7-09” lawyers have become savvy media campaigners who strike a rare balance of staging publicity stunts Chinese authorities appear to loathe, yet generally treat with a light touch.

In April, Li and her friends walked 60 miles to Tianjin to demand answers about her locked-up husband before being turned back. A month later, German Chancellor Angela Merkel invited her to a meeting during a trip to Beijing as a gesture of support.

With no end to her husband’s ordeal in sight, Li said she would continue to demand access to his court hearings or to visit. She intends to demonstrate outside the Supreme People’s Court in Beijing if Wang’s case continues to stall, she said.

“As a wife, I have the right to know the truth,” she said. “When the authorities tell me I cannot know this, or I cannot go there, they never can provide reasons. They just use the logic of having more power or more bodies to stop me.

“All I can do is persist,” she said. “I will persist until I cannot anymore.”