Scandals in New Jersey aren’t confined to bridge lane closings or politicians getting caught in videos agreeing to take pathetically small bribes. Let me show you a different kind of Jersey scandal — something that has been blessed by lawyers and advisers and is totally legal. But something that’s a terrible deal for the taxpayers of New Jersey, including me, and for most state bondholders (that’s me, again).

No, I’m not part of the kick-Chris-Christie crew: I voted for him twice and would do so again if he were running against the same opponents. I’m telling you this tale because other governments will likely be doing what Jersey did in March: restructure financially distressed tobacco bonds.

Bloomberg lists 24 issuers (20 states, the District and three territories) with a total of $38 billion of tobacco bonds, about 20 percent of which are distressed. Keep your eyes on those re-fis.

Tobacco bonds are revenue bonds backed by payments that governments get under the 1998 master settlement with tobacco companies, such as Altria and R. J. Reynolds. Payments are below projections because the manufacturers’ U.S. sales have suffered, for numerous reasons.

New Jersey, for example, pledged to set aside 76 percent of its tobacco-settlement revenue to pay people who bought the $3.6 billion of tobacco bonds the state issued in 2007; but just seven years later, that revenue has fallen short and no longer covers the bonds’ interest and principal payments. The other 24 percent of tobacco revenue, currently about $60 million a year, went to the state’s general fund.

In New Jersey’s case — and in most, if not all, the 23 others — the issuer has no legal or moral obligation to pay tobacco bonds. That’s why the two lowest classes of Jersey tobacco bonds — 1-B and 1-C — traded at depressed levels for years. These bonds, originally rated investment grade, tumbled deep into junk territory. These are zero-coupon bonds that pay no cash interest, and their holders weren’t going to get a penny until the $3.4 billion of tobacco bonds ranked ahead of them were paid in full.

Now watch how this complicated deal — which I think I’m the first person to ever explain in simple language — came to pass.

Last year, according to the New Jersey state treasury, Barclays approached it about strengthening the two wheezing bonds while also maximizing cash for the state. After examining proposals from five other firms, the state hired Barclays, a leading tobacco-bond house.

Like every player but the state treasury, which was quite helpful, Barclays declined to comment. So I’ve based this account primarily on my interpretation of public records.

Three sophisticated investors controlled most of the troubled New Jersey bonds. One, an $8.4 billion hedge fund called Claren Road, whose management company is 55 percent owned by Carlyle Group, had bought up the majority of the less-troubled 1-B issue in the market. I don’t know exactly how many 1-Bs it owned, but I know that it’s a lot. Claren Road also had some walking-dead 1-C bonds.

About 75 percent of the 1-Cs were owned by Goldman Sachs and Oppenheimer mutual funds, which, by my read of public records, had bought them at original issue in 2007 and sold them in the first quarter of this year, taking steep losses.

After months of negotiations, Barclays arranged for the state to buy in most of the 1-Bs and 1-Cs at above-market prices. The state paid about 16 percent of face value for the 1-Bs, and about 9 percent for the 1-Cs, which had been trading at about 12 percent and 5 to 6 percent of face value respectively, according to the Municipal Securities Rulemaking Board’s database of municipal-bond transactions.

Now, watch. After buying in the bonds, New Jersey committed its 24 percent of tobacco payments to back the 1-Bs and 1-Cs. It then sold those now-A-rated securities back to Claren Road and possibly other players for about 22 percent of face value, or $96.5 million more than it paid for them. After fees — primarily $4.47 million for Barclays (for creating and implementing a deal that I consider imaginative and smart, even though I dislike it) and $266,000 to Standard & Poor’s for re-rating the “enhanced” bonds — the state netted $91.6 million, a welcome budget windfall. (Of course, for that quick trading windfall, it gave up a revenue stream.)

The big winner seems to be Claren Road, which had apparently accumulated its 1-B position over several years at a cost well below the 16 cents on the dollar the state paid it for them. Soon after paying the state about 22 cents on the dollar, Claren unloaded its holdings at about 24 cents, a nifty extra profit.

Why do I say that this deal, which was blessed by sophisticated lawyers and sophisticated advisers, hurt New Jersey? It’s the difference between accounting math and real-world math.

It will take about seven years for the 24 percent of tobacco revenue to pay off the 1-Bs and 1-Cs, after which the $60 million a year will flow back to the state’s general fund.

The state hails this enhancement deal as a triumph because it got the aforementioned $91.6 million of upfront money and says it will be able to pay off its other tobacco bonds by 2041 rather than 20 or 30 years later. That earlier-than-projected redemption will allow the 76 percent of tobacco payments devoted to those bonds to flow to the general fund decades earlier than projected. The state values this prospect at $45.1 million (in today’s dollars) more than leaving things as they had been.

So why do I think the state made a bad deal for everyone other than tobacco-bond holders and the people trying to balance its 2014 budget? Here’s why: The state, which is having problems generating the cash necessary to meet its obligations, is diverting about $420 million of cash money — $60 million a year for seven years — from the general fund to the 1-B and 1-C bonds in return for $91.6 million today and something 27 years down the road. Maybe.

I think taxpayers would be better off had the state kept the cash to help its troubled pension funds (on which it could earn a nice return if it invested well), to pay for services or to pay its non-tobacco bonds, or both, such as the transportation trust fund issues that I own.

Why did the state bail out the 1-Bs and 1-Cs, for which it had no legal or even moral obligation? “We respectfully disagree” with the argument that there’s no need to help those issues, treasury spokesman Chris Santarelli said in an e-mail. “The state sees an advantage in maintaining good relations with the tobacco bond investors as they are likely to invest in other bonds of the state.”

Nevertheless, my bottom line remains: This is a brilliant deal — but one that shouldn’t have been made. And I think the state’s blowing smoke.

End note: Even though I voted for Chris Christie twice, I’m now on the lookout for gridlock-creating lane closures near my house. 

Additional reporting by Marty Jones.

Sloan is Fortune magazine’s senior editor at large.