However the environmental group has claimed a cheaper and quicker alternative to build - the "blue route" - was not given enough consideration.

Transport Minister Edwina Hart had said she expected a challenge to the route.

The £1bn scheme is the largest capital investment programme ever announced by the Welsh government.

The favoured route was one of three options put forward for consultation last September.

A so-called "blue route" was put forward as a fourth option three months later by transport expert Professor Stuart Cole.

It is understood that this route was also considered as part of the final decision making process.

But when the black route was named as the preferred option in July, Friends of the Earth Cymru director Gareth Clubb questioned whether the blue route had been "given a fair crack of the whip".

On Friday, he said: "European and Welsh law require the Welsh government to consider a variety of options with an open mind in its transport planning in order to make sure that unnecessary environmental damage is avoided.

Three of the route options including the black route, which Transport Minister Edwina Hart has backed

"We don't think they've done that - and we're willing to seek a judge's opinion on the Welsh government's ability to comply with the law".

Lawyers acting on behalf of Friends of the Earth Cymru have written to the Welsh government saying it must re-start its consultation on improvements to the M4 or face the prospect of legal action.

It said in only looking at a new motorway south of Newport and two similar variations, the Welsh government unlawfully limited the range of "reasonable alternatives".

Following the July announcement, Transport Minister Edwina Hart defended her decision but said she was "sure there'll be a challenge".

"With something like this, with passions on all sides, I know there's concern for the environment - we've had a lot of lobbying," she said.

"I'm sure there'll be a challenge but you tell me what major infrastructure project - HS2 or anything else - is not subject to a challenge.

"That is the reality of the world we work in, that's the reality of the world I work in," she added.

A spokesperson for the Welsh government said on Friday that it had received the legal letter, and would respond "in due course".

"The plan we have adopted will improve accessibility for people, Welsh goods and services to international markets by addressing capacity and resilience issues on one of the main gateways into Wales," they added.