Denmark’s center-right opposition parties have beaten the ruling coalition after a close general election in the country.
With all mainland votes counted, ex-PM Lars Lokke Rasmussen’s center-right group beat PM Helle Thorning-Schmidt’s center-left coalition, although her party is the largest.
Helle Thorning-Schmidt has now stood down as Social Democratic Party leader.
The right-wing, anti-immigration Danish People’s Party will become the second-largest in parliament.
The DPP’s leader Kristian Thulesen Dahl had previously poured cold water on the idea of going into government.
Kristian Thulesen Dahl told Denmark’s Politiken he preferred “the little free bird role, which can make the Danish People’s Party come closer to getting our policy through in the real world than you think”.
He could yet be in a position to make a bid to become prime minister.
In a victory speech just before 01:30 local time, Lars Lokke Rasmussen – who led Denmark between 2009 and 2011 – said: “Four years ago, we returned the keys to the PM’s office. I said that time that they were only a loan.”
He said he would push for “control of the flow of refugees”.
Helle Thorning-Schmidt’s governing Social Democratic Party was the biggest party, winning at least 26.3% of the vote, according to Danish broadcaster DR.
Her allies failed to gain as much of the vote as those of the opposition and she stood down as leader after conceding defeat.
Helle Thorning-Schmidt said she was proud to have led the Social Democratic Party to the highest percentage of the vote, adding: “We lost at the finish line.”
According to DR, the Danish People’s Party won 21.1% of the vote, and Lars Lokke Rasmussen’s Denmark Liberal Party came third on 19.5%.
Denmark is voting in a general election on Thursday, June 18.
According to opinion polls, PM Helle Thorning-Schmidt’s center-left coalition and the centre-right opposition led by ex-PM Lars Lokke Rasmussen, appear to be neck and neck.
However, the pollsters have only canvassed the Danish mainland – and voters in Greenland and the Faroe Islands may decide the vote.
Minor issues like a Faroes fishing dispute could influence the result.
The islands’ fishing community is still angry at Helle Thorning-Schmidt for barring its boats from Danish ports in a 2013 dispute over alleged overfishing.
In reality it is the economy, rather than mackerel quotas, that tends to swing elections, and Helle Thorning-Schmidt’s Social Democrat party has staged a remarkable comeback in recent weeks as Danish finances improve.
Welfare and immigration are exercising Danish voters even more than the economy, with anger at perceived benefit tourism leading the traditionally pro-immigration Social Democrats to launch an advertising campaign with the slogan: “If you come to Denmark you should work.”
Lars Lokke Rasmussen, who led the country between 2009 and 2011, has suggested that benefits are so high that there is barely any incentive for Danes or immigrants to work.
Hours before the polls opened, party leaders took part in the final debate on Danish TV.
A poll released on June 16 put the centre-left bloc – the Social Democrats and their four coalition partners – on 50.1% and the centre-right bloc led by Lars Lokke Rasmussen on 49.9%.
Either one of Helle Thorning-Schmidt’s and Lars Lokke Rasmussen’s parties could win the most seats, only to find themselves the loser if the other can muster a larger coalition.
Polling suggests that Danes are looking outside of the two main parties for alternatives.
One of them, called the Alternative, is a green party that has the potential to tip the balance in the favor of the centre-left coalition.
On the other side, the Liberal Alliance is drawing young libertarians away from the centre-right.
The gunman believed to have attacked a free-speech debate and a Copenhagen synagogue was 22, born in Denmark and known to them because of past violence, police say.
The presumed gunman was shot and killed early on Sunday morning by police who were monitoring an address in the Norrebro district of the city.
The man’s name has not been confirmed.
A film director and a synagogue guard were killed in separate attacks. Five police officers were also injured.
Police believe the gunman was acting alone.
He was known to them in connection with criminal gangs and had convictions for violent offences and dealing in weapons.
“It was the case that when the suspect was shot and killed during police action, he was armed with pistols,” police commissioner Thorkild Fogde told a news conference.
Danish media have widely named him as Omar El-Hussein, but police did not release the suspect’s identity.
The attacks began on Saturday, February 14, when the gunman fired shots at a cafe hosting a seminar on free speech. It was attended by cartoonist Lars Vilks, who has faced death threats over his caricatures of the Prophet Muhammad.
The gunman opened fire again in the early hours of Sunday outside a synagogue in Copenhagen.
The Danish intelligence service is investigating whether the gunman was copying the shootings in Paris last month, when 17 people were killed in attacks on the satirical magazine Charlie Hebdo and HyperCacher kosher supermarket.
Earlier, the head of the intelligence service told reporters the man had been known to them, and police were working to determine whether he had travelled to Syria or Iraq.
PM Helle Thorning-Schmidt described the shootings as “a cynical act of terror against Denmark” and said her government would not compromise on its defense of free expression.
Helle Thorning-Schmidt later visited the synagogue and said Denmark would do everything to protect its Jewish community.
Denmark prides itself on being one of the few European countries to have saved most of its Jewish population from the Nazi Holocaust in the 1940s.
“When you mercilessly fire deadly bullets at innocent people taking part in a debate, when you attack the Jewish community, you attack our democracy,” Helle Thorning-Schmidt said on a visit to the synagogue on February 15.
“We will do everything possible to protect our Jewish community.”
Israeli PM Benjamin Netanyahu has urged Danish Jews to emigrate to Israel. Denmark’s Chief Rabbi Jair Melchior said he was “disappointed” by Benjamin Netanyahu’s stance, the AP reported.
“If the way we deal with terror is to run somewhere else, we should all run to a deserted island,” said Jair Melchior, according to AP.
There has been widespread international condemnation. The US State Department tweeted: “We stand with the people of Denmark and all who defend the universal right of freedom of speech and stand against anti-Semitism and bigotry.”
Patrick Pelloux, a Charlie Hebdo columnist, said: “We are all Danish tonight.”
Danish PM Helle Thorning-Schmidt was among more than 40 world leaders marching arm in arm during Sunday’s historical rally in Paris after multiple acts of violence by Islamic extremists.
But Helle Thorning-Schmidt, 48, had trouble exiting the steps at the Elysee Palace and fell to the ground.
The Danish prime minister was photographed tumbling down the steps of the Elysee Palace on January 11 while wearing a long purple coat and black heeled boots.
The pictures show Helle Thorning-Schmidt walking down the steps perfectly fine but then losing her balance as she heads towards the bottom. She fell forward onto the concrete ground but her hands and knee stopped the fall.
Helle Thorning-Schmidt appeared to be OK as she was helped back up to her feet.
President Barack Obama was caught smiling and taking a selfie with his seat-mates, Denmark’s PM Helle Thorning-Schmidt and Britain’s David Cameron during Nelson Mandela’s massive memorial service in Johannesburg.
As the three of them smile for the camera, a stern-looking Michelle Obama can be seen staring straight ahead, hands clasped.
Michelle Obama’s reaction – not just to the “selfie” but to her husband’s chatting and joking with the young Danish prime minister – was priceless. In one picture, Michelle Obama could be seen glaring over at Barack Obama while he put his hand on Helle Thorning-Schmidt’s shoulder.
In another, it appeared the first lady and the president switched seats, putting Michelle Obama squarely between him and Helle Thorning-Schmidt.
Barack Obama was caught smiling and taking a selfie with Helle Thorning-Schmidt and David Cameron during Nelson Mandela’s massive memorial service
The photographer behind the “selfie” pic of the three dignitaries, though, later claimed that the first lady herself was “joking with those around her” a few seconds earlier.
“The stern look was captured by chance,” he wrote.
After the images surged through social media, the White House on Wednesday released its own set of photos of Barack Obama’s South Africa visit and among them was a picture of Obama, the first lady and the Danish prime minister.
But in this one, Barack Obama was talking to his wife, while Helle Thorning-Schmidt seemed preoccupied with her phone.
The “selfie” incident was the second unexpected controversy stirred up by the president in South Africa. Earlier, Cuban-American lawmakers publicly objected after Barack Obama – on his way to deliver his tribute to Nelson Mandela – shook the hand of Cuba’s President Raul Castro.