The legal opinion, given by Mr Antonio La Pergola, follows a case brought by an army cook, Angela Sirdar, who was turned down for a kitchen job in the Royal Marines on the grounds that the crack unit has a policy of not employing women.
Mrs Sirdar, who took her case to a St Albans industrial tribunal after she was mistakenly offered a transfer to the Marines, had worked as an army cook since 1983.
Under UK law the Government retains the right to exclude women soldiers from units, like the Royal Marines, which are likely to be involved in "close and kill" actions. A Ministry of Defence spokesman said that in the Marines all personnel, including cooks, were expected to be capable of "killing with bayonets".
He said: "Front-line units need to be single-sex for reason of comradeship, loyalty and shared training. The introduction of a second relationship to these units means they won't operate effectively in securing beachheads and breaching enemy lines. The conditions can be extremely harsh."
The Advocate General's opinion makes it clear that in peacetime such a restriction is in breach of the equal treatment directive. If the 12 judges of the European Court follow his opinion, and it is rare that they do not, then the Royal Marines and other ground combat units, such as the SAS, may be forced to allow women to fight on the front line.
An MOD spokesman said: "We are in favour of retaining the status quo. We hope the court will agree with us but if it doesn't then we will have to consider a number of positions."
An ECJ ruling against the UK would mean that other European countries like Italy and Germany, where women are either barred or are restricted to medical roles in the armed forces, would have to change policies. The Advocate General said the equal treatment directive is of "universal scope" and that it applies to the "field of internal safety". He said there was no exemption for "military activities".
But the Ministry of Defence argues the nation's ability to defend itself should be a matter for each individual nation.
Apart from the Navy, where women are not allowed to serve on submarines because of the potential risk to foetuses from the contamination of recycled air, the rest of the armed services admit women personnel in non-front line roles. Overall, 70 per cent of positions in the Army, 76 per cent in the Navy and 96 per cent in the RAF are open to women.
The Advocate General urged the UK to continue with its own review of the policy of excluding women from close combat positions. The Ministry of Defence said the result of the review is not expected for several years.