Participants waved red and yellow Spanish flags and called on Sanchez to resign, the AFP reported. Some held up signs with a photo of the Socialist premier calling him a “traitor”.
Around 30,000 people gathered in Madrid's Cibeles Square for the rally, according to the central government's delegation in the Spanish capital. Organizers said some 700,000 people had taken part.
The protest was called by dozens of right-leaning civil society groups and backed by conservative parties including the main opposition conservative Popular Party (PP) and Vox.
The right is angered by the government's decision to abolish the crime of sedition, of which nine separatist leaders were convicted over their role in the Catalonia region's abortive secession bid in 2017.
It was replaced with an offense carrying a lower prison sentence.
Conservatives are also angered by a flagship law against sexual violence that toughened penalties for rape but eased sentences for other sexual crimes.
Spain will vote in May in regional and local elections.
Lacking a parliamentary majority, Sanchez's government has been forced since its formation to negotiate with Basque and Catalan separatists to pass bills, which has angered many on the right.
Conservatives accuse Sanchez of having eliminated the crime of sedition to assure the continued support of the Catalan pro-independence party ERC in tight parliamentary votes.
But the government argues sedition is an antiquated offense that needed to be replaced with one better aligned to European norms.
MNA/PR