Spain’s former leader told the Supreme Court on Wednesday that Catalan separatist leaders should bear full responsibility for the chaos and clashes during their 2017 independence referendum, insisting that he played no part in directing the national police to use force to block people from voting.

Mariano Rajoy, the former prime minister, was the most prominent among the many witnesses called to testify during the landmark trial of 12 former leaders of the Catalonia region of Spain. They are facing prison sentences of up to 25 years if convicted on charges of staging a rebellion during the botched attempt to secede unilaterally from the rest of Spain in October 2017.

In an attempt to turn the tables on Spain’s central government, a defense lawyer for the separatists showed Mr. Rajoy television footage of the chaotic and unconstitutional referendum in October 2017, in which Spanish police officers were filmed hitting voters with their truncheons.

“I have sadly seen many images of this kind during my life,” Mr. Rajoy told the court. “What I would like to say is that the responsibility of political leaders is to avoid events like those that we have seen. If they acted by respecting the law, we would not have seen these images, nor other similar ones.”