Ai Weiwei, the Chinese artist held by the authorities for almost three months earlier this year, has attacked injustice in China in a passionate article fuelled by his own experiences of detention.

He accused officials of "deny[ing] us basic rights" and compared migrant workers to slaves, describing Beijing as "a city of violence" and "a constant nightmare".

But one of the most powerful passages describes how people "become like mad" as they are held in isolation and how detainees "truly believe [captors] can do anything to you".

His remarks, in an article about Beijing published on the website of Newsweek magazine, are certain to anger Chinese security officials. They come days after it emerged that China is reportedly planning to give police legal powers to hold some suspects for up to six months without telling their families. Campaigners say the move would legitimise and potentially increase the number of secret detentions.

Ai's own 81-day detention caused an international outcry. It was the most high-profile case in a sweeping crackdown that saw dozens of activists, dissidents and lawyers held earlier this year.

State media said he was held for economic crimes and released in June "because of his good attitude in confessing" and a chronic illness. His family and supporters believe he was targeted due to his social and political activism.

The 54-year-old artist is not able to give interviews but confirmed that he had written the article. He described it simply as "a piece about the place I live in".

Ai's bail conditions reportedly prevent him from discussing what happened to him in detention, although a source gave Reuters a detailed account of events, which included more than 50 interrogations.

The restrictions are also said to ban him from using social media – although he sent a brief flurry of angry tweets recently about friends who had been enmeshed in his case – but not from writing.

"The worst thing about Beijing is that you can never trust the judicial system," he wrote in the Newsweek article. "It's like a sandstorm … everything is constantly changing, according to somebody else's will, somebody else's power."

He went on: "My ordeal made me understand that on this fabric, there are many hidden spots where they put people without identity … only your family is crying out that you're missing. But you can't get answers from the street communities or officials, or even at the highest levels, the court or the police or the head of the nation. My wife has been writing these kinds of petitions every day [while he was held], making phone calls to the police station every day. Where is my husband?

"You're in total isolation. And you don't know how long you're going to be there, but you truly believe they can do anything to you. There's no way to even question it. You're not protected by anything. Why am I here? Your mind is very uncertain of time. You become like mad. It's very hard for anyone. Even for people who have strong beliefs."

The artist described the capital as two cities. The first was one of power and money, peopled by officials, coal bosses and the heads of big companies who help to keep "the restaurants and karaoke bars and saunas … very rich". The second was a place of desperation, he wrote, calling migrant workers the city's slaves.

Ai, who helped to design the "bird's nest" national stadium for the Olympics – but publicly turned on the games before they began – said none of his art represented the capital.

He added: "The Olympics did not bring joy to the people."

He also warned: "Beijing tells foreigners that they can understand the city, that we have the same sort of buildings …

"Officials who wear a suit and tie like you say we are the same and we can do business. But they deny us basic rights."

Ai described people giving him quiet support when he went out last week, for example patting him on the shoulder, but only in "a secretive way" because they were not willing to speak out.

He said people told him to "either leave, or be patient and watch how they die. I really don't know what I'm going to do."