By Gary O'Donoghue
Political correspondent, BBC News
So after months of arm-twisting and telephone bashing, Gordon Brown has got his way.
The proposals will face stiff opposition in the Lords
In the event of a "grave and exceptional threat" the police will be able to ask the home secretary to ask Parliament if an individual can be locked up for 42 days without any charges being brought.
The concessions have been numerous - some on questions of principle, some not.
For example, bringing the matter before Parliament more quickly and tightening the definition of a "grave and exceptional threat" are all perfectly reasonable grounds for discussion - but the suggestion that one MP was offered a safe seat if he promised to come on side, may not be quite so high minded.
And then there is the question of the last minute concession offered by Jacqui Smith - an ex-gratia compensation scheme to pay those who have been detained beyond 28 days and then released without charge.
In this realm of new legal principles, this is yet another - the idea that those lawfully held could find themselves in the money if no charges are brought.
The victory has been at a high price for Gordon Brown.
Not only have his appeals to principle and loyalty fallen on deaf ears among almost 40 of his own backbenchers, but he has also had to end up relying on the votes of someone else's party to get his way.
Sixty six is a decent working majority in historical terms, and to find yourself, a year into your leadership, at the whim of nine Democratic Unionists scarcely smacks of being in control.
Of course, the prime minister set out on this path last autumn at a time when he was riding high.
He dealt with a summer of crises successfully - so what better way of showing he could do things Tony Blair could not by pushing this through, where his predecessor had failed.
But following the election that never was and the subsequent difficulties over Northern Rock, missing government data, the economic downturn and the 10p tax row, the 42 day vote became increasingly important - the way back from the brink and a means to demonstrate that he could be steadfast.
Whether this proves to be a turning point is impossible to know at present.
Much will depend on broader political issues such as the state of the economy and the price of things such as fuel and food.
It is unlikely, however, that the prime minister will want to pick another fight with his party in the short term.
They clamoured for him to take over and twelve months down the line some of them are treating him like the enemy.
There is still the question of the House of Lords and what peers might do to this legislation.
There is substantial opposition to the plans there, and the government does not have an overall majority in the upper house.
So fresh battles on this issue loom for Gordon Brown, he may just have to go through this arm-twisting all over again if peers drive a coach and horses through the plans.
But for today this is of course a victory and that is what counts - time will tell whether it is pyrrhic or not.