Labour has vowed to vote against the bill, describing it as a cynical "power grab" by Prime Minister Theresa May.

The bill is likely to pass its second reading but faces possible Tory rebellions during later stages of the bill.

Ministers likely to make concessions to MPs in order to pass first of eight Brexit-related bills.

LONDON — MPs will shortly after midnight tonight vote on the EU Withdrawal Bill in what will be the first big parliamentary test of Theresa May's Brexit plans. Opposition parties have vowed to vote against the bill, describing it as a cynical "power-grab" and some Tory MPs are also mulling a possible rebellion.

So what is the bill, why is it proving so controversial, and is there any chance the prime minister could be defeated?

What is the EU Withdrawal Bill?

The EU (Withdrawal) Bill, formerly known as the Great Repeal Bill, has been sold as a means of "taking back control" of UK laws from the EU. Under the bill, all existing EU laws will be transferred over to British law, after which the government will be free to rewrite or repeal them at will.

It sounds brilliantly simple, but in reality, it is a legal, regulatory and political nightmare. Here's why:

Repealing EU law is a logistic nightmare

Theresa May Jack Taylor / Getty The prime minister announced last year that she would effectively remove Britain from all EU law. She said she would do this through a "Great Repeal Bill" which would "remove from the statute book - once and for all - the European Communities Act."

This would ensure that "our laws will be made not in Brussels but in Westminster. The judges interpreting those laws will sit not in Luxembourg but in courts in this country. The authority of EU law in Britain will end."

Of course, it's not quite as easy as that. Were the prime minister to simply scrap all EU laws, Britain would grind to a halt. So, in the interim period, the PM plans to take a "snap shot" of all existing EU laws and transfer them over to UK law where they can later be amended or scrapped at will.

There's one big problem with this.

There's too much of it.

Getting rid of EU law isn't simply a case of repealing one act and cutting and pasting it over into UK law. According to the EU, there are around 20,000 EU legislative acts in force, of which 5,000 apply to all member states. And while some of it is effective by virtue of the ECA, much of it isn't.

Huge parts of EU law are already embodied in both primary and secondary UK legislation, while other parts are not really laws at all but judgments made by the Court of Justice, or rulings by EU regulators. Deciding which parts of this will need to adopted or amended is a bureaucratic nightmare that would take many years to do properly. Britain will have about 18 months.

As Daniel Greenberg, a former Parliamentary council and expert on legislative law, told Business Insider, reviewing all that EU law to see what should be transferred, ditched or amended will be "a civil service legal exercise on a scale that has not been encountered at any other time in our recent legal history."

It's still changing.

REUTERS/Francois Lenoir The other problem is that we won't know what laws we want to keep until the Brexit negotiations are over.

May has promised to secure a free-trade deal with the EU, but in order to do so, she will have to accept the continuation of a certain amount of EU laws and regulations, particularly in those areas that govern trade. Quite how much she will have to accept depends on negotiation, which almost certainly won't conclude until the last minute. This creates another problem.

We don't have time.

Unpicking thousands of pieces of legislation and asking Parliament to vote on which bits to keep and which bits to scrap would take decades, several governments and would almost certainly be impossible. Because of this, the government has another plan and here's where it becomes politically very tricky.

Delegated powers and Henry VIII clauses

BBC There's only really one solution to May's difficulties and that is to bypass Parliament altogether. This can be done through the use of delegated powers, statutory instruments and so-called Henry VIII clauses. These all allow the government to amend laws without first facing full parliamentary scrutiny.

These powers were intended to be used by governments only for minor time-sensitive technical changes to laws and indeed hundreds are passed every year. However, the time pressures caused by May's Brexit timetable means that they will have to be used much more widely and liberally through the EU Withdrawal Bill.

Opposition politicians are extremely worried about this

Christopher Furlong/Getty Images As the House of Lords Constitution committee warned last week, the EUWB will hand ministers wide-ranging powers to that are "breath-taking in terms of both their scope and potency."

They warn that it will allow the government "effectively unlimited powers" to changes large areas of UK law without any effective scrutiny by Parliament.

As the human rights organisation Liberty has also warned, it will hand ministers "virtually untrammelled power" to make and unmake whole swathes of our law. Everything from workers rights' to food standards, to banking regulations, will suddenly be up for grabs by Downing Street and it will all happen so quickly that we won't even realise what we've lost until it's gone.

Of particular concern is the clause in the bill stating that the Charter of Fundamental Rights will not be incorporated into UK law.

As Martha Spurrier, Director of Liberty, said earlier this year. "If the Repeal Bill passes in this state, people in the UK will lose rights after we leave the EU,"

"It is that simple and the stakes are that high."

Because of this, Labour and other opposition parties have demanded major changes to the bill when it passes through its committee stage later this year. With Tory rebellions likely, May faces defeat unless she gives ground.

Could May lose tonight's vote?

Carl Court / Getty Labour leader Jeremy Corbyn has urged his party to vote against the bill tonight at second reading. However, a number of his own backbenchers, and possibly even some frontbenchers, are likely to rebel against him and there is no sign of a big Conservative rebellion at this stage of the bill. As a result, the bill is likely to pass comfortably tonight.

The real problems for May will come later when MPs vote on detailed amendments to the bill. Here May could face some difficulty, even from some hardened Brexiteers who are worried about the scale of powers the bill will hand ministers.

With no overall majority in parliament, the prime minister will almost certainly have to give ground in the coming weeks or face defeat.

Will she get through it?

Failure to pass this bill would effectively amount to a vote of no confidence in May's government and leave her position fundamentally untenable. As a result, Tory MPs are unlikely to pull the trigger and the bill is likely to pass in some form or another. However, with a total of seven other highly controversial Brexit-related bills that the PM needs to pass before Britain leaves the EU in Spring 2019, May has a huge task to undertake if she hopes to still be sitting in Downing Street by the time Brexit is complete.