The front lawn of the Ontario legislature was crammed with teachers Tuesday in a massive protest of a controversial bill that would freeze wages and cut benefits to pare down the province's $15-billion deficit.

Members of the Elementary Teachers' Federation of Ontario, the Ontario Secondary School Teachers' Federation and the Canadian Union of Public Employees carried signs and flags calling for the minority Liberals to negotiate with them, rather than legislate. In total about 4,000 protesters attended.

Three unions representing about 45,000 teachers and school workers agreed to the two-year framework agreement with the province, which the government is now trying to impose on all the others.

But the three other unions, representing about 191,000 members, opposed the deal and are fighting the legislation.

The bill, which will likely become law with the Progressive Conservatives' backing, would also ban strikes and lockouts for at least two years.

Teacher Mary Mays Stewart travelled to Toronto from Muskoka to take part in Tuesday’s protest.

"It’s not about putting kids first, it’s about stripping us of our right to negotiate a contract like any other unionized employee in this province," she told CBC News.

The bill could be passed as early as Thursday.

While the teachers chanted and waved signs outside, Premier Dalton McGuinty defended the bill inside the legislature.

Money is needed to roll out full-day kindergarten and avoid bigger class sizes, so teachers can't get a pay hike, he said.

"We can't afford [to raise teachers' pay] right now," McGuinty said during question period. "We're not prepared to do that, and I think teachers understand that."

But neither the premier nor Education Minister Laurel Broten signalled their willingness to go out and talk to the protestors.

Asked whether she was afraid to go and face them, Broten said she has talked to them on "many occasions."

"My message to teachers has been consistent, has been loud and clear," she said.

"We appreciate the work that you do. You do important work. We are simply asking at this point in time that we see a pause in terms of pay increase, that we have to make choices, that we have to put our students first."

Key byelections loom over teacher pay debate

But the real purpose of the bill isn't to rein in spending or prevent labour disruption in the province's schools, but to distract voters from the government's embarrassments, critics said.

McGuinty is trying to change the channel from scandals like Ontario's troubled air ambulance service — which is currently under  a criminal probe — and the $190-million bill for cancelling a gas plant in the last election to save Liberal seats, said New Democrat Peter Tabuns.

The teachers' bill is in fact meant to divert voters' attention to a nonexistant crisis in schools to win two byelections on Sept. 6 that could give them a majority government, he said.

The Liberals currently control 52 of the 107 seats in the Ontario legislature, while the Tories hold 36 seats and the New Democrats have 17.

"Is the government ready to stop playing politics and work to get a solution that actually works for students, their parents and a public that's fed up with paying the price for this government's quest for a majority?" Tabuns asked McGuinty in the legislature.

Progressive Conservative Leader Tim Hudak — who has agreed to help pass the bill — had no plans to talk to the protesting teachers either, saying he had to attend a caucus meeting.

"We're going to bail Dalton McGuinty out because he's messed up this deal with the teachers," he said. "I want to make sure the kids are back in school on the first day, so that bill will pass, but now that is going to be behind us we've got to get serious about the big issues in the province, balancing the books, creating jobs."

With files from CBC News