BRUSSELS — The European Union’s top court has ruled that Britain can change its mind over Brexit, boosting the hopes of people who want to stay in the EU that the process can be reversed.

The European Court of Justice ruled Monday that when an EU member country has notified its intent to leave, “that Member State is free to revoke unilaterally that notification.”

Britain voted in 2016 to leave the 28-nation bloc, and invoked Article 50 of the EU’s Lisbon Treaty in March 2017, triggering a two-year exit process.

Article 50 contains few details, in part because the idea of any country leaving was considered unlikely.

A group of Scottish legislators had asked the ECJ to rule on whether the U.K. can pull out of the withdrawal procedure on its own.