The leader of the Scottish National Party, Nicola Sturgeon, leaves a polling station in east Glasgow. (Robert Perry/AFP/Getty Images)

Scottish leaders who overwhelmingly supported Britain’s membership in the European Union warned Friday of possible renewed bids for independence after British voters turned their backs on the 28-nation bloc.

Nicola Sturgeon, leader of the Scottish National Party, said a second referendum on Scotland’s membership in the United Kingdom was a possibility in the immediate future.

“We will begin to prepare the legislation that would be required to enable a new independence referendum to take place if and when Parliament decides,” she told reporters in Edinburgh.

Just two years ago, pro-E.U. Scottish voters rejected independence and opted to remain united with England, Wales and Northern Ireland.

Meet the European leaders hoping to cause the next Brexit

In that earlier vote, the separatist campaign could not successfully demonstrate that a newly independent Scotland would automatically earn E.U. membership: For Scottish Europhiles, the safest option in the September 2014 referendum was to remain in the U.K.

But Britain’s rejection of the European Union has outraged millions in Scotland as well as in Northern Ireland, pointing to the internal pressures the U.K. faces as it looks toward the difficult process of breaking with its European partners.

If Brexit will redefine the relationship of Britain with continental Europe, it could also significantly alter the borders of the U.K. itself.

Passport-control checks and physical barriers could soon be installed between the Republic of Ireland and Northern Ireland, the only portion of the U.K. that will now share a land border with an E.U. member state.

In Thursday’s vote, 56 percent of voters supported the pro-E.U. “Remain” camp in Northern Ireland, where significant E.U. investment has meant a new chapter of prosperity for a region that has not forgotten decades of sectarian violence.

Sinn Fein, the Irish nationalist party dedicated to ending British jurisdiction over Northern Ireland, immediately announced that the Brexit results justified a united Ireland.

“English votes have overturned the democratic will of Northern Ireland,” Declan Kearney, Sinn Fein’s national chairman, said in a statement Friday morning.

“This British government has forfeited any mandate to represent the economic or political interests of people in Northern Ireland,” he said.

Likewise, 62 percent of Scottish voters sided with the Remain camp, compared with just 47 percent in England.

“I am proud of Scotland and how we voted yesterday,” Sturgeon said. “We proved that we are a modern, outward-looking and inclusive country, and we said clearly that we do not want to leave the European Union.”

“Decisions have consequences,” Fiona Hyslop, Scotland’s external-affairs minister, told reporters. “If the United Kingdom has made a decision against the interests of the Scottish people, that will have consequences.”

In Wales, where 52 percent of voters backed Brexit, despite the billions of euros the region has received from Brussels in structural funding, First Minister Carwyn Jones was quick to express displeasure with the vote.

In a statement, Jones said the referendum was grounds for an entire reworking of the political relationships among Britain’s devolved capitals, putting the country onto an “entirely different footing.”

The potential details of a second Scottish referendum remain unclear, as do those of a newly independent Scotland’s accession to the E.U.

Sturgeon declined to comment, and the Scottish National Party declined to elaborate on her Friday morning speech.

A second Scottish referendum would probably occur in a notably different economic environment than in 2014. For one, Scotland ran up a deficit last year roughly twice the size of the rest of the U.K.’s, due among other things to lower tax revenue from fallen oil prices.

A second Scottish referendum could also lead to border controls between Scotland and an England increasingly wary of E.U. migrants. Those potential borders could curb the billions of pounds of commerce that flow between the two countries every year.

For many, the vote has already struck at the heart of the United Kingdom, politically integrated since 1707.

J.K. Rowling, the Scottish author of the best-selling Harry Potter books, tweeted Friday that Scotland will surely “seek independence now.”

“Cameron’s legacy will be breaking up two unions,” she wrote of the British prime minister. “Neither needed to happen.”