The right leaning Demokraatit Party won the most votes in Greenland’s parliamentary elections, a surprise result as the territory went to the polls in the shadow of US President Donald Trump’s stated goal of taking control of the island.

Both Demokraatit — the Democrats — and the second place party, Naleraq — Point of Orientation — favour independence from Denmark.

But Demokraatit’s upset victory over parties that have governed the territory for years indicates many in Greenland care just as much about social issues such as healthcare, education, cultural heritage and other social policies.

Members of the Naleraq party applaud during a party after parliamentary elections in Nuuk, Greenland (Evgeniy Maloletka/AP)

The unanticipated results came after huge crowds streamed into the polling station in the capital Nuuk throughout the day, warmed by sunny skies. Exhausted voting officials closed the polls well after the planned 8pm local time on Tuesday to make sure everyone in line got a chance to cast their ballot.

Prime minister Mute Bourup Egede in February called elections a bit early, saying the country needed to be united during a “serious time” that is unlike anything Greenland has ever experienced.

Mr Trump has been outspoken about his desire to control Greenland, telling a joint session of Congress last week that he thought the US was going to get it “one way or the other”.

Greenland, a self-governing region of Denmark, straddles strategic air and sea routes in the North Atlantic and has rich deposits of the rare earth minerals needed to make everything from mobile phones to renewable energy technology.

Mr Egede’s Inuit Ataqatigiit (United Inuit) had been widely expected to win the contest, followed by Siumut — two parties which had dominated Greenland’s politics in recent years.

People line up outside a polling station to cast their vote in parliamentary elections in Nuuk, Greenland (Evgeniy Maloletka/AP)

A break from Denmark was not on the ballot, but it was on everyone’s mind. The island of 56,000 people has been on a path towards independence since at least 2009 and the 31 politicians elected will shape the island’s future as it debates whether the time has come to declare independence.

Four of the five main parties in the race sought independence, but disagreed on when and how.

Naleraq is the most aggressively pro-independence, while Demokraatit favours a more moderate pace of change.

“What approach to independence will win the day will ultimately depend on if Demokraatit decides to form a coalition government, and if so, with which party,” said Dwayne Menezes, managing director of the Polar Research and Policy Initiative.