Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

CHARLESTON, W.Va. — The West Virginia teachers' strike is headed for the history books.

Gov. Jim Justice on Tuesday afternoon signed a bill delivering a 5 percent pay raise to public school teachers — and extending to all state employees — ending a contentious strike that shuttered schools in West Virginia for nine days.

The deal, passed unanimously by both houses of the state Legislature earlier in the day, will send 20,000 teachers across the state away from the picket lines and back into classrooms. It's the first salary increase in four years for state educators, The Associated Press reported.

"It's a historic day," Dale Lee, the president of the West Virginia Education Association, told NBC News. "It's West Virginia finally investing in education instead of just funding it."

Hours later, teacher unions across the state agreed over a conference call to officially end the strike. Schools across the state were expected to reopen Wednesday.

Hundreds of teachers who'd filled the State Capitol building in Charleston awaiting the announcement broke out in cheers, and they later sang John Denver's "Take Me Home, Country Roads" after the governor said the deal was done.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"We are making an investment, we are putting education where it ought to be, and that is first," Justice told reporters moments before signing the bill.

"Today is a new day for education in West Virginia going forward," he added. "We're not looking back."

We have reached a deal. I stood rock solid on the 5% Teacher pay raise and delivered. Not only this, but my staff and I made additional cuts which will give all State employees 5% as well. All the focus should have always been on fairness and getting the kids back in school. — Governor Jim Justice (@WVGovernor) March 6, 2018

A quarter of a million students across the state's 55 counties have been out of school since the strike began Feb. 22 over teachers' pay and health care.

The average salary for West Virginia teachers in 2016 was ranked 48th in the nation, according to the National Education Association. The typical teacher in the state was paid $45,622 a year, compared to the national average of $58,353.

"We are fed up. Enough is enough," Jamie Heflin, 38, a single mother who teaches at Lenore K-8 School in Williamson, told NBC News last week. "We're tired of the disrespect."

Justice, a Republican, had pushed for a 5 percent raise last week, but Senate Republicans wouldn't agree without cuts elsewhere in the budget. Senate Finance Chairman Craig Blair, a Republican, said the raises will be paid for with $20 million taken from elsewhere in the state budget, including Medicaid.

The strike kept about 277,000 students and 35,000 employees across the state's public schools out of classrooms, according to the AP, forcing parents to find day care and make other arrangements for their children. Missed school days must be made up, but individual counties will decide whether to add days to the end of the school year.

"This is an opportunity to at least retain the most highly qualified teachers in West Virginia," said Christine Campbell, the president of the American Federation of Teachers West Virginia.

Teachers react to news that West Virginia Gov. Jim Justice and Senate Republicans have reached a tentative deal to end a strike by giving them 5 percent raises. Craig Hudson / AP

West Virginia's service personnel and state police are also covered in the law raising wages.

The teachers' work stoppage has inspired educators facing low pay in other states to consider their options. On Thursday, the Oklahoma Education Association teachers union is expected to announce a plan for a potential strike.

"This historic action in West Virginia will inspire others," Lee said on MSNBC. "This is just the first step."

Ron Allen reported from Charleston, and Ethan Sacks reported from New York.