WORCESTER, Mass. — The American Civil Liberties Union on Monday filed a federal lawsuit against the city, claiming that two new anti-panhandling ordinances violate the constitutional right to free speech.

The city passed the local laws in January to outlaw certain types of aggressive panhandling, including soliciting money from motorists while standing in the street or on a traffic island or while walking in and out of traffic. Advocates said the laws were needed to protect public safety.

The ACLU’s lawsuit says the ordinances are overly broad, prohibit a wide range of peaceful activities that don’t implicate safety concerns, and unfairly target the poor and the homeless.

“Our goal is to reaffirm that Worcester’s poorest residents can seek help in ways that clearly are not aggressive and that all Worcester residents can use traditional forums for free speech,” said Kevin Martin, an attorney with the law firm which is handling the case for the ACLU of Massachusetts.

The plaintiffs in the lawsuit are two homeless people and a member of the Worcester School Committee.

The ordinances prohibit all solicitation for 30 minutes before sunset and anytime after sunset. They also create no-solicitation zones throughout the city by barring solicitation within 20 feet of the entrances or parking areas of theaters, banks, public restrooms, bus stops, outdoor cafes, restaurants or other outdoor seating areas.

The lawsuit says the ordinances also prohibit any type of speech on a traffic island or roadway, barring homeless people and local politicians from holding signs in those areas.

The lawsuit seeks an injunction prohibiting the city, about 40 miles west of Boston, from enforcing the ordinances and a ruling declaring them unconstitutional.

City Solicitor David Moore said he believes the ordinances don’t infringe on free speech.

“We understand there is a First Amendment aspect to panhandling,” he said. “We didn’t ban it, but there is a public safety concern. We think the ordinances will pass the constitutional test.”

Moore said the ordinances seek to stop aggressive panhandling in areas where people have money, including at ATMs and bus stops, and where people are in the street asking motorists to stop and make donations.

“Peaceful panhandling is perfectly legal,” Moore said. “There’s a public safety concern with stopping traffic in order to make this exchange.”