China has been ruled by the Communist Party as a one-party state since 1949. Under the current administration of President Xi Jinping, authorities have tightened control over academics, lawyers and the media, activists say.
Drawing on Germany's history and his own life in the former East Germany, President Joachim Gauck, whose role is largely ceremonial, condemned "dictatorship" to students at Shanghai's prestigious Tongji University.
"Most people were neither happy nor liberated," he said of East Germany under Communist rule. "And the entire system lacked proper legitimacy.
"Free, equal and secret public elections were not held. The result was a lack of credibility, which went hand in hand with a culture of distrust between the rulers and those they ruled," he added, according to an official English translation of his speech.
"It was a state that, as part of the union of Communist countries dependent on the Soviet Union, silenced its own people, locked them up and humiliated those who refused to comply with the will of the leaders."
His outspoken comments are a marked contrast to most diplomatic visitors to China, who prefer to focus in public on the benefits of trade ties with the world's second-largest economy.
Gauck, who was in the commercial hub Shanghai as part of an official visit, said Germany was "concerned" about recent news regarding China's civil society though he gave no specific examples.
"Vibrant and active civil society always means an innovative and flexible society," he said.
He also told the students that academic freedom could benefit society.
"A university has to be a place of unhampered research and free and frank discussion," he said, speaking in German with translation into Chinese to an audience of around 100 students and professors.
"This freedom is a precious commodity."
Gauck dismissed the notion that human rights as outlined under a United Nations declaration were a "Western product".
"Even if the universal applicability of human rights does not yet mean that every person can de facto enjoy those rights... they can nonetheless lay claim to them," he said.
Last month, China rejected as "irresponsible" comments by UN rights chief Zeid Ra'ad Al Hussein calling for the immediate release of rights lawyers and activists detained by Beijing.
Zeid had raised concerns about the arrests of an estimated 250 lawyers and activists in a crackdown since July.
A day before Gauck's speech in Shanghai, the English-language edition of the Global Times newspaper said that human rights were not a priority and were only a "trivial matter" for his visit.
"The West should evaluate China's human rights based on the facts. The progress China has made in its 1.3 billion citizens' rights of life and development deserve applause," the newspaper, known for its nationalistic stance, said in an editorial.