Labour will take action in the courts to prevent Boris Johnson from pushing through a no-deal Brexit against the will of parliament, Keir Starmer has pledged.

The shadow Brexit secretary said that if the prime minister is unable to reach an agreement with Brussels by 31 October, he must comply with the Benn act and seek a further delay.

In a speech at the Co-operative party conference in Glasgow, Starmer said: “If he can’t – or I should say won’t – get a deal we will take whatever steps are necessary to prevent our country crashing out of the EU without a deal.

“If no deal is secured by this time next week, Boris Johnson must seek and accept an extension. That’s the law. No ifs, no buts. And if he doesn’t, we’ll enforce the law – in the courts and in parliament. Whatever it takes, we will prevent a no-deal Brexit.”

Starmer dismissed suggestions that the prime minister could circumvent the law by accompanying a request for an extension with a second letter to the EU saying he did not want one.

“That’s the equivalent of attaching a Post-it note to divorce papers saying ‘only kidding’ – It’s a ridiculous idea,” he said.

Officials are continuing talks in Brussels over the weekend after the EU’s chief negotiator, Michel Barnier, gave the go-ahead on Friday for intensive negotiations to start.

Starmer said that if the prime minister succeeded in getting an agreement, Labour would demand it was put to the public in a referendum.

Quick Guide Why is the Irish border a stumbling block for Brexit? Show Counties and customs Inside the EU, both Ireland and Northern Ireland are part of the single market and customs union so share the same regulations and standards, allowing a soft or invisible border between the two.

Britain’s exit from the EU – taking Northern Ireland with it – risks a return to a hard or policed border. The only way to avoid this post-Brexit is for regulations on both sides to remain more or less the same in key areas including food, animal welfare, medicines and product safety. The 'backstop' in Theresa May's Withdrawal Agreement was intended to address this - stating that if no future trade agreement could be reached between the EU and the UK, then rules and regulations would stay as they are. This has been rejected by Brexit supporters as a 'trap' to keep the UK in the EU's customs union, which would prevent the UK striking its own independent trade deals. There are an estimated 72m road vehicle crossings a year between Northern Ireland and the Republic of Ireland, and about 14% of those crossings are consignments of goods, some of which may cross the border several times before they reach a consumer. Brexit supporters say this can be managed by doing checks on goods away from the border, but critics say it will be difficult to police this without any physical infrastructure like border posts or cameras, which could raise tensions in the divided communities of Ireland.

Interactive: A typical hour in the life of the Irish border Photograph: Design Pics Inc/Design Pics RF

The Labour MP and former director of public prosecutions added that with parliament to sit in a special emergency session next Saturday, it appeared any agreement would be “even worse” than Theresa May’s rejected deal.

“No level playing field protections. No customs union. A green light to deregulate. That kind of deal can never be one Labour supports,” he said.

Earlier on Saturday, Nicky Morgan said the prospects of a Brexit deal appeared to be “promising” after the meeting between Johnson and Ireland’s Leo Varadkar.