CHICAGO (Reuters) - Chicago teachers will end their 11-day strike against the third-largest U.S. school system after their union and district officials reached a tentative settlement on Thursday of a labor dispute that canceled classes for 300,000 students.

The five-year contract includes funding for more than 400 additional social workers and nurses, spending the union argued was necessary to allow teachers to focus on curriculum, according to the union.

It was the second-longest in a wave of U.S. teachers’ strikes that has played out across West Virginia, Oklahoma, Arizona and California over the past few years, topped only by a three-week June strike in Union City, California.

Like the earlier walk-outs, Chicago teachers had pushed for more money to ease overcrowded classrooms and more support staff, in addition to seeking a wage increase for the district’s 25,000 teachers.

A tentative deal reached late on Wednesday fell apart when the two sides disagreed over how many missed school days for students - and days of pay for teachers - would be tacked onto the end of the school year. The agreement reached on Thursday calls for five, less than the 11 the union had sought, the union said.

It was an early test of first-term Democratic Mayor Lori Lightfoot, who campaigned on improving the city’s schools but said the school district could not afford the sharp increases in spending on counselors and nurses that teachers sought.

“It was important to me that we got our kids back in class. Enough is enough,” Lightfoot said during a news briefing after the deal was reached. “I think it was the right thing for our city and I am glad this phase is over.”

Union members expressed frustration that Lightfoot had been unwilling to extend the school year by 11 days to make up for the lost classes. Pressure for a settlement had ramped up in recent days as teachers braced for their first paychecks reduced by the strike, as well as the prospect of health insurance expiring on Friday.

“This fight is about black children and brown children in the city of Chicago getting the resources in their school community that they have been deprived of for generations,” union Vice President Stacy Davis Gates said during a news conference after the announcement.

FILE PHOTO: Teachers protest during a rally and march on the first day of a teacher strike in Chicago, Illinois, U.S. October 17, 2019. REUTERS/John Gress

The tentative agreement includes enforceable staffing increases of 209 social workers, amounting to one in each school, a case manager in each school and 250 additional nurses by the end of the contract, the union and district said.

The district also committed to spending $35 million to reduce oversized classrooms and prioritizing schools that serve the most vulnerable students. Classroom size caps will be enforceable, the sides said.

The agreement comes with an average raise of 16% across the board for teachers and most union members over the life of the contract, along with a pay hike on average of 40% for teaching assistants, clerks and other workers, the union said.

Crowds of teachers wearing red T-shirts took to Chicago’s streets during the strike’s two weeks, picketing some of the 500 schools across the city and holding rallies and marches in downtown Chicago.

U.S. presidential hopeful Bernie Sanders, a Democrat, congratulated the union on Twitter.

“Unions are on the front lines of the struggle for justice in education, and I stand with them in this important fight for what Chicago’s students and families deserve,” the U.S. Senator from Vermont said.

Democratic presidential contender Senator Elizabeth Warren on Oct. 22 joined the striking teachers on the picket line, and strikers also joined in protests against Republican President Donald Trump during his visit on Monday to Chicago.

The work stoppage forced officials to cancel classes, but school buildings stayed open for children in need of a place to go during the strike.

The strike angered parents and students, particularly the families of student athletes, as the walkout coincided with state-wide play-offs, which teams have competed for months to attend, and where college talent scouts look for candidates for athletic scholarships.

The strike came seven years after Chicago teachers walked out for seven days over teacher evaluations and hiring practices. In 2016, teachers staged a one-day walkout to protest the lack of a contract and failure to stabilize the school system’s finances.

Chicago resident Jackie Rosa thanked teachers for their “fearless fight” and courage in holding out for a deal.

“You put your bodies on the line to bring TRUE EQUITY to our children,” Rosa said on Twitter. “Chicago owes you everything.”