Denmark intends to hold a referendum on whether to keep its opt-outs from the European Union’s justice and home affairs rules, the prime minister, Helle Thorning-Schmidt, has said.

In a speech at the annual opening of parliament, Thorning-Schmidt said Denmark may have to leave the European cross-border crime agency Europol as soon as next autumn due to exemptions that were making it increasingly difficult to remain within the European policing agency.

The referendum would allow Danes to opt in to EU legislation on a case-by-case basis, she said. “Then we can choose ourselves which parts of EU cooperation within justice affairs we should be part of, and which ones we shouldn’t be part of.”

Denmark rejected the EU Maastricht treaty in 1992 but adopted the document in a second referendum in 1993 after obtaining exemptions on the euro, joint defence, judiciary cooperation and European citizenship.

Thorning-Schmidt said a new referendum would be held after the next election, which has to be held in September next year at the latest.

Denmark’s centre-left coalition currently looks set to be voted out of office amid discontent over austerity measures and a sluggish recovery, but the plans for a referendum were also welcomed by the opposition.

“It is something we have been calling for for a long time,” a spokesman for the right-of-centre Venstre party told the Danish daily Berlingske.

He said leaving Europol would “have serious consequences for the Danish police’s ability to combat transnational crime”.