It’s a deal.

Premier Dalton McGuinty has agreed to NDP Leader Andrea Horwath’s “tax-the-rich” scheme in order to ensure the minority Liberals’ budget passes Tuesday, averting a snap election call.

McGuinty emerged Monday afternoon from a 30-minute closed-door meeting with Horwath — his second in as many days — to announce he had made significant compromises to win her backing.

“They wanted a tax on the rich, I wanted to pay down our deficit faster,” the premier told a packed news conference.

“We all gave a little bit,” he said, referring to the new “NDP surtax” on people earning more than $500,000 a year.

Horwath told reporters after McGuinty’s news conference that “our caucus does not intend to defeat the government. We will not be plunging this province into an election.”

She won a huge victory by convincing the Liberals to impose the 2 per cent surtax on 23,000 high-income earners that would raise $470 million in 2013-14 with all proceeds going toward paying down the $15.2 billion deficit.

The tax — which would cost someone making $600,000 an extra $3,120 annually — will be in place until Ontario balances the budget, now scheduled for 2017-18.

Horwath also said the 1 per cent increase to Ontario Works welfare benefits and Ontario Disability Support Plan, which will cost the government $55 million, made the budget “a little more fair.”

That will be offset by lowering the price the province pays for its 10 most popular generic drugs by $55 million.

An infusion of $20 million to help hospitals in Northern Ontario, where the NDP holds a majority of the seats, will be paid for by reducing the budget for government consultants.

As well, there is an unspecified plan to help the horse-racing industry once slot machines are removed from racetracks by next March.

Last Friday, McGuinty also pledged $242 million in funding for child care over three years, which will come from the education budget.

Still, the NDP leader could not yet say if her 17-member caucus would actually vote for the budget on Tuesday or merely abstain.

“Did we get everything that we wanted, absolutely not . . . We’ve had some partial wins,” she said, adding New Democrats are still determining their precise course of action in Tuesday’s 11:45 a.m. budget vote.

The mood had been tense earlier Monday at Queen’s Park over concern the province could be faced with a second election just seven months after the Oct. 6 campaign that resulted in a minority Liberal government.

“I really don’t want an election right now. People will be angry at us if it happened,” said a grim-faced Finance Minister Dwight Duncan before the agreement was reached.

Horwath’s proposal is popular with Ontarians — a Forum poll last week suggested 78 per cent support with only 17 per cent opposition — and many Grit MPPs urged McGuinty to adopt the levy.

But last week the premier expressed reservations in part because he still bears scars from raising taxes after the 2003 and 2007 elections despite promising not to do so.

At the Liberals’ caucus meeting last Tuesday, MPPs and cabinet ministers spoke overwhelmingly in favour of making the concession to Horwath — to McGuinty’s chagrin.

On Monday, Grit MPPs confided that they hoped the premier would cede to their wishes.

“It’s a lot easier to ask government workers to take a wage freeze if we’re also asking a little bit from our wealthiest residents,” said one Liberal MPP, referring to plans to freeze wages for doctors, teachers, nurses, and hundreds of thousands of others on the public payroll.

With 52 Liberal MPPs, excluding Speaker Dave Levac, in the 107-member Legislature, the governing party needs opposition support to pass the budget Duncan tabled March 27.

Progressive Conservative Leader Tim Hudak and his 37-member caucus vowed to defeat the spending plan from the get-go.

“I would like to say I am surprised by this deal but I’m not. What I am concerned about is the direction of Ontario,” Hudak said in a statement late Monday.

“We need to reduce the size and cost of government and kick-start growth and job creation in the private sector,” added the Tory leader.

The Conservative strategy of disengagement, which even some senior Tories are now questioning, forced the Liberals to negotiate exclusively with the New Democrats to prevent a $100-million election.

If the government had fallen Tuesday, Ontarians would likely have gone to the polls on May 24.