ALBANY — Personal income taxes for the upper middle class and the rich are about to skyrocket under a secret, soak-the-wealthy tax deal reached last night by Gov. Paterson and leaders of the Legislature, sources told The Post.

The two-tier tax plan would bring in $4 billion annually, in part by hiking income taxes a stunning 31 percent for all New Yorkers making more than $500,000 a year, sources said.

A second, slightly lower tier would increase incomes taxes by 14.5 percent for singles earning $250,000-$500,000 annually and for married and joint filers earning $300,000-$500,000.

Taxpayers now hit the current top rate of 6.85 percent when their incomes reach $65,000. The Paterson plan would tax top-tier earners at 8.97 percent and second-tier earners at 7.85 percent.

The staggering hike was one of the last elements of a $121 billion spending deal Paterson and legislative leaders forged behind closed doors in a race to make the Aprilñ1 budget deadline.

Its inclusion in the budget represents a dramatic retreat for Paterson, who repeatedly argued such a proposal would drive some of the most productive citizens out of the state and stunt any economic recovery. A Paterson spokesman did not return a call.

Although the rates are lower, the proposal closely resembles a plan advocated by labor unions and liberal Democrats for years in an effort to undue much of the tax cuts secured by Republican Gov. George Pataki in the mid-1990s.

Advocates repackaged the effort as the “Fair Share Tax Reform” this year as a way to stave off harsh spending cuts and nuisance taxes pushed by Paterson to close the ever-worsening budget gap.

That plan called for a top rate of 10.3 percent and would have brought in more than $6 billion.

“We’re gratified that something very similar to our Fair Share Tax Reform made it into the final budget,” said state Sen. Eric Schneiderman (D-Manhattan), a sponsor of the plan.

“This is not just about filling a hole in the budget. It’s about righting a wrong.”

Assemblyman Darryl Towns (D-Brooklyn), who led the tax-the-rich initiative in the Assembly, said the final didn’t raise enough money.

“I’m not sure that proposal goes far enough to restore progressivity to the system,” Towns said.

The effort to raise taxes gained steam in recent weeks as the budget deficit swelled from the $13 billion to $14 billion and finally to $16.2 billion last Tuesday. Republican lawmakers charged that the increasing deficit numbers were a “set up” for the tax-hike plan.

The agreement comes at the same time Washington lawmakers are weighing a similar tax-the-rich plan advocated by President Obama.

Lawmakers could vote on the tax plan as soon as Tuesday. It’s unclear whether it can pass the narrowly divided Senate where rural and suburban Democrats have expressed concern about supporting a tax hike that cuts so far down the income scale.

Assembly Speaker Sheldon Silver (D-Manhattan) pushed for a three-tiered tax hike that would expire after five years. Senate Majority Leader Malcolm Smith (D-Queens) responded with a $5 billion plan that would include $1 billion for property-tax relief and expire in three years.