The former Conservative PM said a bill allowing ministers to override parts of the deal would break international law and damage the UK's reputation.
Other Tories criticised the plan, which faces an initial Commons vote later.
But Foreign Secretary Liz Truss said there was no other option to "fix" problems the deal has created.
The bill would allow ministers to change the part of 2019 deal that introduced post-Brexit checks on goods sent from Great Britain to Northern Ireland.
The border checks were designed to avoid checks at the UK's border with the Republic of Ireland, but is highly unpopular among unionists in Northern Ireland.
The bill began its journey through Parliament on Monday, with MPs due to vote later on whether it should proceed for further scrutiny.
Some Tory MPs have joined opposition parties in warning that the legislation breaches international law, and could join them in voting against it.
It is not expected, however, that any rebellion would block the progress of the bill at this stage.
Speaking in the Commons, Ms Truss argued the bill was justified because the EU had not shown enough "flexibility" during negotiations change the relevant part of the 2019 deal, known as the Northern Ireland Protocol.
She told MPs that ministers expected the passing of the bill to lead to the resumption of power-sharing in Northern Ireland, which has been put on hold since May's assembly elections.
Nationalist party Sinn Féin won the most seats in May's elections, but the Democratic Unionist Party (DUP), which came second, is refusing to re-enter a power-sharing executive until its concerns about the protocol are addressed.
Speaking to reporters earlier, DUP leader Sir Jeffrey Donaldson said the party would "consider what steps we can take" if the bill gets through all its Commons stages intact.
Supporting the bill during the Commons debate, he said the protocol had had a "devastating impact" on Northern Ireland.
Ms Truss added that the bill was justified by the "worsening situation" in Northern Ireland, and the UK had been left with "no other choice" because the EU had ruled out changes to the text of the 2019 agreement the UK had signed.
She added that the move was legal because changes to the protocol were required to preserve Northern Ireland's 1998 Belfast/Good Friday peace agreement.
However, Ms May - who as prime minister started Brexit negotiations in 2017 before quitting in 2019 after failing to get her exit deal passed in Parliament - said the bill would fail to achieve its aims.
"Necessity suggests urgent," she told MPs - before adding: "There is nothing urgent about this bill".
"It has not been introduced as emergency legislation. It's likely to take not weeks but months to get through Parliament," she added.
She said she had concluded it was "not legal", and would "diminish the standing of the United Kingdom in the eyes of the world".
Fellow Tory Simon Hoare, who chairs the Commons Northern Ireland Committee, said the bill represented "playing fast and loose with our international reputation" - whilst former Tory international development secretary said it "brazenly breaks" the UK's obligations.
Labour has vowed to vote against the bill, with shadow foreign secretary David Lammy saying it would alienate the UK's allies, and risk a trade war with the EU during a "cost of living crisis".
Although sating that the EU had been "too rigid as well," he said it would be better for the UK to continue negotiations with the EU.
Earlier, Prime Minister Boris Johnson said he believed the bill on the Northern Ireland Protocol could be passed by the end of the year.
Speaking to the BBC at the G7 summit in Germany, Mr Johnson said the government's plan could be carried out "fairly rapidly".
The government is aiming to fast track the bill through the House of Commons before the summer recess in mid-July.
It is expected to face stern opposition in the House of Lords, however - with Mr Hoare predicting it could take until next spring to get it through Parliament.
The bill has also prompted a backlash from the EU, which said it would be restarting legal action against the UK after the legislation was published.
* The Northern Ireland Protocol is part of the Brexit deal: it means lorries don't face checkpoints when they go from Northern Ireland (in the UK) to the Republic of Ireland (in the EU)
* Instead, when goods arrive in Northern Ireland from the rest of the UK (England, Scotland and Wales), they are checked against EU rules
* The UK and the EU chose this arrangement because the Irish border is a sensitive issue due to Northern Ireland's troubled political history