Spain has dropped a judicial investigation into alleged genocide and human rights violations against a number of Chinese leaders in Tibet.
The High Court said the case did not comply with new legislation that limits Spain's ability to investigate crimes against humanity committed abroad.
China welcomed the decision - the investigation had threatened to damage relations between the two countries.
The case was initially brought by a Tibetan monk, who is a Spanish citizen.
Among those named was China's former president Hu Jintao, who was the Communist Party leader in Tibet in 1988-1992 when Chinese troops quelled mass protests and imposed martial law.
The remote mountainous territory is an autonomous region ruled by Beijing.
Under new rules which became law in March, Spanish judges can still pursue crimes against humanity committed abroad, but the suspect must be Spanish or a foreign resident in Spain.
Madrid denies the new law is a response to complaints by Beijing.
Spain has pioneered what is known as universal jurisdiction.
The best known case saw former Chilean dictator Augusto Pinochet detained in London in 1998 on a Spanish warrant. He was later returned to Chile on health grounds and did not stand trial in Spain.