At the start of the year, the SPD looked set to comfortably win the state election in North Rhine-Westphalia (NRW), with polling showing the centre-left party between five and ten points ahead of their conservative rivals.
But when the results came through on Sunday evening, they revealed that the CDU had pushed their noses ahead at the finishing line, gaining 33 percent of the vote in comparison to 31.2 percent for the SPD.
The victory was only the second time the CDU have won NRW in 50 years, and means the conservative party have now come out on top in three out of three state elections in 2017, putting them on track to win the national elections in September.
Here’s how the CDU won in the working-class heartland of Germany.
1. Convincing non-voters to turn up
A huge element in the CDU victory was the result of people who were previously non-voters turning up to vote for them. A total of 430,000 of the new votes for the centre-right party came from people who didn't cast a ballot in the last election, according to a poll by Infratest dimap published by ARD on Tuesday.
2. Pinching votes from the SPD
The second largest voter group won by the CDU was people who had previously put a cross next to the rival SPD. 310,000 people switched from centre-left to centre-right in this election - bad news for SPD leader Martin Schulz, who was been taking the party further to the left since he was elected leader in January.
3. Tired of incumbents
The same ARD survey showed that only 45 percent of voters in NRW were satisfied with the SPD party’s coalition with the Greens. Polling in states which have recently had elections showed much higher approval ratings.
In Baden-Württemberg, 70 percent of voters said they were satisfied with the state Green-led coalition before last year's election. In Saarland 69 percent of voters expressed satisfaction with the state government before the vote this spring. In both states the incumbents strengthened their grip on power.
4. Dotting their i’s.
In the ARD survey, 29 percent of respondents said that the most important issue for them in the NRW vote was education, making it the single most relevant issue in the election.
And despite the SPD pumping large amounts of money into the state’s education system over the past seven years, it is clear they didn't do enough to convince voters on this issue.
The education ministry in NRW raised its annual budget from €13.9 billion in 2010 to €17.9 billion last year. And whereas in 2010 only 14 percent of kids under three were in kindergarten, that number has now gone up to 26 percent.
But the state still lags behind the rest of Germany. If you send your kids to school in NRW, they will have €800 less spent on them in a year than the German average.
And in a high profile cock-up, the SPD managed to make a spelling mistake in an advert boasting about their own achievements for the education system - hardly a signal to the public that they warranted a further five years looking after their kids' education.
The feelings of NRW voters on the matter were relatively clear. Only 31 percent told Infratest dimap that the SPD were competent on the issue of education, compared to 37 percent who said the same of the CDU.
4. It’s the economy, stupid
Putting the former engine room of the German economy back on its feet was another thing voters tended to trust the CDU with.
NRW has one of the highest unemployment rates in the country and by far the highest level of public debt of any of the 16 states - both signs it has never fully recovered from deindustrialization in the 1970s.
Despite the fact that unemployment has dropped by 74,000 people over the past six years, NRW voters clearly weren't happy with the progress. In fact, in the same time Saxony and Thuringia (both states run for the majority of this period by the CDU) have overtaken NRW on the employment rankings.
On the question of who is more trusted at handling the economy, 47 percent of NRW voters said the CDU would do a good job. Only 28 percent replied that the SPD were specialists in this arena.
The CDU provided a positive message of change on education, as well as rebuilding infrastructure.
"We want to make sure our state stops languishing at the bottom of the list of states. NRW has all the potential to become one of the top German states," party leader in NRW Armin Laschet told the Berliner Morgenpost on Tuesday.
5. Battling crime
NRW has made headlines for all the wrong reasons over the past two years on criminality. First, hundreds of women reported being sexually assaulted in Cologne over New Year's Eve 2015-16, with police and the state interior ministry being accused of a cover-up in the aftermath of the crimes.
Then it was revealed that the state had failed to arrest the man who drove a truck into a Berlin Christmas market in December, killing 12 people.
Only 23 percent of voters told pollsters that they trusted the SPD to fight criminality. Meanwhile 48 percent said the same of the CDU.
And much of the anger was directed against one man - SPD interior minister Ralf Jäger. One in every two respondents said that he had failed in his job.
6. Magnet Merkel
In a sign of how quickly political fortunes can change, the polling showed that Merkel was a massive draw for voters who decided to vote CDU.
Seventy percent of respondents said they believed that Merkel makes sure that Germany is successful in an unstable world. Meanwhile 59 percent were of the opinion that the Chancellor is the most important reason that one could vote for the CDU.
This is quite a turnaround for the most powerful woman in Germany, who last year was accused of costing her party votes in state elections with her controversial open-door refugee policy.
Merkel turned up on numerous occasions in NRW to support party candidate Armin Laschet, who is one of her closest allies.
"Politics on the state level were the key factor, but the Chancellor's many appearances across the state supplied us with strong support," Laschet said.