Three years after a landmark agreement to cut class sizes in New York City’s public schools, classrooms are swelling across the city, a result of budget cuts and spending decisions that have reduced the teaching force.

According to the city’s Department of Education, elementary schools this year had the largest increases, with average class sizes growing to 23.7 students per class from 22.9 last year. In middle schools, class sizes climbed to 27 from 26.1; high school class sizes held at about 27.

Small classes are increasingly rare. Excluding special education classes, 22.4 percent of elementary and middle school students were in classes of 20 or fewer children two years ago. Now, only 13.7 percent are. Meanwhile, the percentage packed into classrooms with 28 students or more has jumped to 31 percent from 23 percent, according to an analysis by The New York Times.

The increases come despite a city commitment since 2007 to reduce class sizes across all