Organizers said 120,000 people attended the march, but police estimated about 18,000 people attended the first major separatist march in the Spanish capital.
Read more: Catalan independence — What you need to know
As the protesters marched through the city some waved the red-and-yellow striped Catalan flag and carried signs. A banner at the front of the march read: "Self-determination is not a crime."
Speaking to reporters at the protest, Catalonia's Regional President Quim Torra said the march in Madrid was needed in order to decry a trial that he described as a "farce."
Catalan politicians face life sentencesNine of the 12 Catalan politicians and activists on trial at Madrid's Supreme Court face up to 25 years in prison on rebellion and other charges for holding a banned independence referendum for the northeastern region and pushing ahead with an independence declaration that Madrid said was illegal.
Read more: Who is former Catalan President Carles Puigdemont?
The trial is about to enter the fifth week of hearings, and sentencing is not expected until after Spain's April 28 general election.
The Catalan crisis will play a major role in the upcoming vote, with three right-leaning parties, the conservative Popular Party (PP), center-right Ciudadanos and the relatively new far-right Vox party all calling for Spain to take a tougher position with separatists.
Polls show the support of Catalan parties may prove decisive if Prime Minister Pedro Sanchez is to form a government after the vote.
Sanchez's Socialists are expected to win the most seats, but they will likely fall short of a parliamentary majority.
Read more: How dangerous is Spain's far-right Vox party?
law/cmk (AFP, AP, dpa, Reuters)
Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.