Britain's 1.3 million agency workers will get the same pay and conditions as permanent staff after being employed for 12 weeks, under an EU deal hammered out in Luxembourg early today.

The talks also updated Europe's working hours deal - keeping the Government's opt-out from a maximum 48-hour week, and restoring flexibility for on-call workers such as junior doctors.

Business Secretary John Hutton emerged in the early hours from the 12-hour meeting of EU employment ministers to describe the outcome as "a very good deal for Britain".

The Government had flatly rejected original EU proposals to grant equal rights from day one of an agency contract and suggested that temps should have at least one year's service to qualify.

Then at the end of last year Mr Hutton angered unions by refusing to accept six weeks as the trigger point for equal employment treatment for temps - on the grounds that obliging companies to match the employment rights of full-time workers would put hundreds of thousands of jobs at risk.

But he accepted a national agreement between the CBI and TUC last month on agency worker parity after 12 weeks in the UK, and unblocked stalled EU negotiations.

Coupled with a continued opt-out for British workers from the 48-hour week, Mr Hutton said the double deal retained crucial job market flexibility.

"It provides a fair deal for workers without damaging Britain's economic competitiveness or putting jobs at risk.

"Flexibility has been critical to our ability to create an extra three million jobs over the past decade. That flexibility has been preserved by ensuring workers can continue to have choice over their working hours in future years."

He went on: "People remain free to earn overtime and businesses can cope during busy times. Securing the right for people to work longer if they choose to do so is hugely valuable to the British economy.

"The agreement on agency working will give a fair deal to agency workers and prevent unfair undercutting of permanent staff while retaining important flexibility for businesses to hire staff on short term seasonal contracts or at key busy times."

The updated deal on working time clarifies the position of "on-call" workers, whose "on-call" time until now has been deemed to count entirely as working time, hugely adding to public sector staffing costs. The new deal distinguishes between "active" on-call time, which counts towards the maximum working week, and "inactive" working time - such as an uninterrupted night's sleep while on call - which does not.

The deal, breaking months of stalemate on a highly controversial area of EU legislation, still has to get approval from the European Parliament - and Liberal Democrat MEP Liz Lynne warned that Gordon Brown's own Labour MEPs could object to the working time deal.

"The Government must remember the agreement runs the danger of being ripped apart by Socialist MEPs who have for years been waiting for these controversial dossiers to return to the European Parliament," she said.

But retaining the opt-out was right, she said. "Anyone whose work does not have a direct consequence on life and death decisions should have a free choice as to what hours they work, so long as this is truly voluntary.

"But the Government must stand firm and ensure flexibility for the UK's labour force. There is one thing Brown can't rely on - the support of his own Labour MEPs," she said.

Before the final result the Government was accused by the Federation of Small Businesses of taking the labour market back to the 1970s by signing up to "damaging" employment legislation.

The FSB said a snap poll of its members showed that 96% of those who relied on agency workers would be less likely to employ them because if the 12-week parity requirement becomes law.

FSB chairman John Wright said: "This deal smacks of the 1970s when major decisions were made behind closed doors and trade unions dictated employment policy to the Government. We cannot take Britain back to those bad old days.

"The Government must not attempt to fool other European leaders into thinking this deal has business support in the UK. As far as Britain's small and medium sized businesses are concerned, this agreement is not in our name."

European Trade Union Confederation General Secretary John Monks, speaking before the talks began, made clear that, while the unions saw equality for temporary workers as a major step forward, the organisation still opposed the UK's "continuing determination" to keep the working time opt-out.

The Federation of Small Businesses said the deal was a "mixed bag" - it welcomed the continued opt-out from the maximum 48-hour week, but condemned the agency workers' agreement which it said would cause "untold damage" to firms' ability to expand.

Tina Sommer, FSB chairman for EU and international affairs, said: "Retention of the UK's Working Time Directive opt-out is welcome, but the price was far too high for employees and employers alike. Why should we be forced to choose between the two?

"While British ministers pop champagne corks and hail this deal as a triumph, Britain's entrepreneurs will be drowning their sorrows. In these difficult economic times, small businesses need to be flexible in order to grow, and this directive will be like a steel rod for their backs.

"The back-room manner in which this deal was negotiated by big business and trade unions should be of great concern to all those who will suffer the consequences."