LOS ANGELES — A tentative deal announced Tuesday could end the six-day teachers' union strike in the nation's second-largest school district.

Negotiators for the Los Angeles Unified School District reached an agreement with the United Teachers Los Angeles in the early hours of Tuesday morning after a 21-hour bargaining session. Teachers are scheduled to vote on the agreement Tuesday, so the earliest they would return to work would be Wednesday.

The agreement includes a 6 percent raise for teachers, smaller class sizes and more nurses and counselors at schools, said Alex Caputo-Pearl, president of the union.

The walkout created chaos in schools responsible for the education of nearly 500,000 students. Mayor Eric Garcetti, a Democrat, joined the talks, which were held at City Hall.

"This is a historic agreement," Garcetti said. "It's time for a new day in public education in Los Angeles."

More strikes ahead? Teachers love their jobs but can't pay their bills, poll shows

Besides its massive scope, the strike has been closely watched nationwide because it raised issues about public education. The L.A. walkout was the latest in a series of high-profile teacher work actions. But unlike labor uprisings in West Virginia and Kentucky, the L.A. strike came in a reliably Democratic area where voters usually support generous bond issues for causes like housing for the homeless and rebuilding public libraries.

More strikes could be on the way. Denver teachers are voting today on whether to strike, and Oakland teachers are set to vote next week on their own strike.

The agreement covered many of the teachers' demands. It reduces the size of some classes by one student in each of the first two years and two students in the third year. The district will hire 41 teacher-librarians this year in each of the first two years. The district will hire 150 nurses in each of two years in order to have one full time at all its schools.

Teachers also won hope on limitations on charter schools, which have been sapping students — and money — from regular public schools. The agreement calls for the board of education to vote for a resolution calling on the state to establish a cap on charter schools.

"This is much more than a labor agreement," said UTLA President Alex Caputo-Pearl. "It's a very broad compact that gets to social justice, educational justice."

Teachers in America:No matter where they work, they feel disrespect

More:'We're just fed up' Teachers running for office in record numbers

It was unclear Tuesday morning how the district will pay for the agreement. Superintendent Austin Beutner repeatedly said better pay and more staff were worthy goals, but the district simply didn't have the money. The district has a savings account of about $2 billion, but Beutner said the money was committed to other needs and draining the reserves would bankrupt the district.

During the strike, teachers braved days of rain as they picketed in front of their schools and rallied downtown. Their position: The district could certainly pony up the cash if pressed. Their anger was usually directed at Beutner. Principals, charged with keeping their schools up and running, praised their teachers and talked of how much they wanted them back in classrooms.

Principals tried to make do with substitute teachers, administrators and volunteers, often unable to do more than try to keep kids occupied and contained in large spaces.

On the strike's first day, many of the 900 schools where teachers walked out kept kids occupied by showing movies, not by holding class. Some principals were able to organize students into a handful of locations where they could participate in indoor sports and take part in rudimentary classroom drills or educational iPad games. None of the students appeared to be picking up studies where their teachers had left off.

With the perception that little was being accomplished in classrooms, and reluctant to have their kids cross picket lines, many parents kept their children at home. Attendance ranged from about 15 percent, including students at charter schools where teachers weren't striking, to about 40 percent.

More:What happens to the 62,500 students with special needs during L.A.'s teachers' strike?

"We want the rest of our kids to come so we can continue instructing them because a day lost is a day of learning that's lost," said Rafael Escobar, principal at Marianna Avenue Elementary School after the first day of the walkout.

Low attendance was costly to the district. After the first week of the walkout, the district said it had cost the district about $125 million from the state without taking into account savings from not having to pay striking teachers.

Attendance was slightly higher in schools with students from lower-income families. But parents expressed frustration about their kids being in classrooms where little was being accomplished.

"They don't have no teacher, no nothing," said Janet Madrigal as she brought son Diego to Florence Griffith Joyner Elementary in the Watts area on the second day of the strike. "They are just watching movies. They aren't learning anything."

She said her son didn't want to come and believes he was trying to fake a tummy ache to get out of it. "He wants to be with his teacher," she explained.

More:Even when teachers strike, Americans give them high grades, poll shows. Unions fare worse.

Out on the sidewalks last week, teachers chanted slogans, held up signs, cheered when passing motorists honked their horns and warmly greeted students when their parents dropped them off or when they were leaving to go home. A few students joined them.

"Teachers are the most important people in my life," said Lola Babich, 15, a sophomore at John Marshall High School in the Los Feliz areas.

Contributing: Kristin Lam