A decree issued by the prefect of Dakar declared there were "real risks" that the rally would be infiltrated by troublemakers and public order and property could be at threat.
It also said the demonstration would breach laws banning "disguised" propaganda taking place within 30 days of the official start of an election campaign.
A barred protest on June 17 led to clashes in which three people died and more than 200 were arrested, according to opposition figures. Two MPs were arrested, one of whom was handed a six-month suspended term on Monday.
Legislative elections in Senegal, a country which generally has a good reputation for stability, are due to take place on July 31, and their official start is July 10.
The ballot is for the 165-seat National Assembly, where supporters of President Macky Sall wield a majority.
Leaders of an opposition coalition called Yewwi Askan Wi are incensed after Senegal's paramount court threw out a list of their candidates on technical grounds.
The move effectively barred a leading opposition figure, Ousmane Sonko, who came in third in the 2019 presidential elections and has already declared he will run in the 2024 ballot.
The country was shaken by several days of rioting in March last year, claiming around a dozen lives, after Sonko was accused of rape.