A federal judge on Tuesday blocked an effort by the city of Boston to shorten this Sunday's St. Patrick's Day parade, saying that city officials would be violating parade organizers' right to free assembly and expression.

Mayor Martin Walsh early this month said the city would cut the 115-year-old parade's permitted route through South Boston by half to 1.6 miles, a move that he said would dramatically cut the cost of policing the event, which draws tens of thousands of sometimes rowdy revelers.

Related: St. Patrick's Parade organizers sue City Hall over shortened parade route

It would have been the second year in a row the parade marched on a shortened route; Walsh last year requested the cut as Boston struggled to clean up a record-setting 9 feet of snowfall.

The parade organizers, the South Boston Allied War Veterans Council, fought the effort to shorten this year's parade, suing the city in U.S. District Court in Boston and contending this year's cuts violated organizers' constitutionally protected rights to free assembly and expression.

The parade is no stranger for controversy. Boston mayors had boycotted it for some 20 years after a U.S. Supreme Court ruled that parade organizers had the right to ban openly gay marchers from participating in the event.

The organizers of New York's St. Patrick's Day parade had enforced a similar ban for decades, saying that allowing openly gay marchers would run afoul of their Roman Catholic heritage. The Catholic church teaches that homosexual activity is immoral.

Both parades gave in to public pressure last year after major sponsors withdrew their support and opened their ranks to openly gay marchers. That led Walsh, Boston's first Irish-American mayor in two decades, to march in 2015.

New York Mayor Bill de Blasio plans to make his first appearance at New York's St. Patrick's Day parade on Thursday.