By James Hardy
Political correspondent, BBC News
The TUC's Brendan Barber has tried to spare Mr Brown's embarrassment
Not content with a punch-up over public sector pay, the unions have decided to square up to Gordon Brown over Europe.
They defied his express wishes by backing a call at the TUC for a referendum on the proposed new EU treaty.
This leaves Mr Brown facing an unholy - and uncomfortable - alliance in favour of a vote between the TUC and the Conservative Party.
But where the Tories want a referendum to limit the influence of Brussels, the TUC is looking to extend it.
Many unions see a referendum campaign as a way to exert pressure on the PM to sign up fully to the European charter of fundamental rights, which guards against employment abuses.
That's a move the government's always avoided, to the anger of the unions, because employers argue it would unfairly skew the labour market.
'Sigh of relief'
But GMB leader Paul Kenny, who moved the successful pro-referendum motion, believes it is also a matter of honour.
Labour went into the 2005 general election with a manifesto pledge to hold a referendum on the now scrapped European constitution.
When Dutch and French voters rejected the constitution, British ministers heaved a sigh of relief because almost no-one believed it was winnable.
Inevitably, once the EU resurrected large parts of the constitution in the form of a treaty, there were calls from opponents for the referendum pledge to be revived.
Until now those have been led by the Tories and the UK Independence Party and there are many at the predominantly pro-European TUC who are wary of giving succour to either party.
That's why TUC general secretary Brendan Barber was desperate to find a solution that would be less embarrassing politically for Gordon Brown.
He was on to a loser from the start.
Mr Kenny and RMT rail union leader Bob Crow - whose own motion calling for the TUC to back a "no" vote in the event of a referendum was rejected - had the support of the biggest unions and weren't prepared to back down.
No amount of arm-twisting by the legion of ministers present in Brighton - and it's rumoured by Mr Brown himself - was going to change that.
So the general council of the TUC, the governing body of made up of the general secretaries, failed to come up with an alternative motion that would have been more acceptable to the government.
That cleared the way for a pro-referendum motion to be adopted.
The RMT's may have failed because it called for the TUC to push for a "no" vote - a step too far for many union members.
In the end, the vote is only symbolic. Mr Brown doesn't have to take any more notice of the TUC than he does of the Tories.
But it will add to a growing impression on the referendum issue that the prime minister is out of step with public opinion.