Nearly 1,000 fewer classes are overcrowded this year compared to last, although thousands of classes continue to pack in more students than is contractually allowed, according to an annual survey conducted last month by the city teachers union.

United Federation of Teachers President Michael Mulgrew attributed the decrease both to a rise in state education funding and the city’s decision to use that increase to hire about 530 additional teachers last school year. He also said more of the state funding made its way into individual school budgets than in the past.

The union has long railed against overcrowding, but with a sympathetic mayor in office it has shifted blame for packed classrooms from the city to the state.

At a press conference Monday, Mulgrew thanked Mayor Bill de Blasio for this year’s drop even as he called on Gov. Andrew Cuomo and state lawmakers to send more funding for smaller classes. Last year, when when the number of overcrowded classrooms crept up, the union did not alert the press.

While school overcrowding tends to be a top concern for teachers and parents, de Blasio has not made that a focus of his education agenda. And it has not been among the initiatives championed by Chancellor Carmen Fariña, who has said that some classes can actually be too small.

“The chancellor might not say this is her main priority; we will continue to advocate that it is a main priority,” Mulgrew said Monday. He added that, “We are moving in the right direction, but we still have a long way to go.”

Across the city, 5,485 classes were overcrowded at the start of the school year, down from 6,447 classes at that time last year, according to the union’s survey of teachers. The latest total is the lowest in recent years, the union said.

Still, more than 3,400 high school classes exceeded the 34 students permitted in the teachers contract, the survey found. In elementary and middle schools, where class size limits range from 25 to 33 students, more than 2,000 classes were overcrowded, the union said. The union typically files grievances in schools where those contractual limits are violated.

Queens high schools saw the greatest drop in overcrowding this year. However, that borough continues to have the most overcrowded classes in elementary, middle, and high schools, according to the survey.

Deborah Alexander, a Queens parent and co-president of the District 30 Community Education Council, said both her children are in elementary school classes that are filled to the contractual limit. In her daughter’s jam-packed kindergarten classroom at P.S. 122 in Astoria, she said, students had to hang their backpacks on their chairs at the start of the year because their teacher was forced to fill bins for their belongings with supplies.

“Even though parents are screaming and crying for class-size reductions, it seems to fall on deaf ears,” she said, adding that is the “number one reason” parents give her when they move their children to private schools.

Advocates have criticized the de Blasio administration for doing too little to address school overcrowding. Earlier this year, the political advocacy group NYC Kids PAC gave the city an F for its class size policies, and an “incomplete” for overcrowding. It pointed out that de Blasio promised to set goals around smaller classes, but has yet to do so.

Leonie Haimson, a member of that group and the executive director of Class Size Matters, said she was unsatisfied with the improvements cited by the union. She said the state should send the city more funding for smaller classes, and the city should work with the union to set lower class-size caps.

“There’s a lack of commitment from the state and city to do anything real on class size,” she said.

City education department officials have said they plan this year to direct state funding allocated for reducing class sizes to the low-performing schools in the city’s “Renewal” improvement program. However, at least 10 of those 94 schools had overcrowded classrooms at the start of the year, according to the union, which added that some of the schools have since shrank some classes.

Education department spokeswoman Devora Kaye said the city shares the goal of reducing class sizes. She would not say whether the city has set any specific targets around class size, or what steps it is taking to create smaller classes in Renewal schools.

In a statement, she said this year’s overcrowding reduction “is a step forward, and we will continue to make progress.”