Some of Massachusetts’s top politicians said on Wednesday that they would not attend the St. Patrick’s Day Parade in South Boston after organizers told a group of gay and transgender military veterans that they would not be allowed to march on March 19 after two years of L.G.B.T. inclusion in the event.

The governor, Charlie Baker, and the mayor of Boston, Martin J. Walsh, both announced their decision to skip the parade over its decision to bar the group, OutVets. In a statement, the mayor encouraged the public to do the same.

“I will not tolerate discrimination in our city of any form,” Mr. Walsh said. “I will not be marching in the parade unless this is resolved. Anyone who values what our city stands for should do the same.”

Mr. Baker said it “doesn’t make any sense” to exclude the group.

“If veterans’ groups aren’t allowed to march in that parade for whatever reason, then I’ll probably do something else,” he told reporters on Wednesday.