Image copyright Alamy

It's no secret that Theresa May lost her majority in June's election and that Jeremy Corbyn won more seats than expected. But what was really behind the decisions made by the UK's voters?

For the past three years the British Election Study has followed a panel of the same 30,000 voters - asking them hundreds of questions about their political views and choices on 13 occasions.

It offers the most detailed look at the issues which most concerned the electorate - and the results are now in.

It really was about Brexit

Despite Mrs May's claim that her reason for calling an early election was to get a mandate for the Brexit negotiations, the issue of Brexit itself had a relatively low profile during campaigning.

For much of the campaign, both the Conservatives and Labour focused on other issues.

But in the minds of the voters at least, the 2017 election was - as it promised to be ever since the referendum of June 2016 - the Brexit election.

This can be seen in our data in many different ways, but nowhere more clearly, perhaps, than in the answer to the question: "As far as you're concerned, what is the single most important issue facing the country at the present time?"

More than one in three people chose Brexit or the EU, compared with fewer than one in 10 who mentioned the NHS and one in 20 who suggested the economy.

The Europe question boosted the Tories and Labour

Of course, actions speak louder than words, and voters were not only concerned by Brexit but actually voted accordingly.

The issue cut across normal party loyalties and contributed to the revival of the Conservative and Labour parties at the expense of challenger parties - including UKIP, the SNP, Plaid Cymru and the Greens - which had done so well in 2015.

Because the British Election Study tracked the same voters during the 2015 election, the EU referendum and the 2017 election, we can see for the first time how voters switched party allegiance depending on their referendum vote.

The Conservatives' position on Brexit, coupled with the absence of Nigel Farage, saw the UKIP vote collapse and the majority of its support go to the Tories.

More than half of UKIP's 2015 voters who voted again in 2017 switched to the Conservatives, compared with only 18% to Labour and a further 18% who stayed loyal.

Labour picked up a few Leave voters, but lost roughly equal numbers to the Conservatives - undoubtedly the party of Leave.

But which was the party of Remain?

Despite having the clearest pro-EU position and a promise of a second referendum, the Liberal Democrats failed to pick up many more Remain voters than they lost.

Instead, Labour, which was already the most popular party in 2015 among those who voted Remain in 2016, scooped the lion's share.

version="1.0" encoding="utf-8"? Conservative April 2017 → Conservative June 2017 35.32 Labour April 2017 → Labour June 2017 25.42 Undecided April 2017 → Labour June 2017 6.69 Liberal Democrat April 2017 → Liberal Democrat June 2017 5.71 Liberal Democrat April 2017 → Labour June 2017 3.37 SNP April 2017 → SNP June 2017 3.13 Undecided April 2017 → Conservative June 2017 3.01 Conservative April 2017 → Labour June 2017 2.88 UKIP April 2017 → Conservative June 2017 1.88 UKIP April 2017 → UKIP June 2017 1.82 Undecided April 2017 → Liberal Democrat June 2017 1.32 Conservative April 2017 → Liberal Democrat June 2017 1.11 Green Party April 2017 → Labour June 2017 1.05 UKIP April 2017 → Labour June 2017 0.98 Green Party April 2017 → Green Party June 2017 0.81 Labour April 2017 → Liberal Democrat June 2017 0.59 Liberal Democrat April 2017 → Conservative June 2017 0.54 Undecided April 2017 → Green Party June 2017 0.48 Conservative April 2017 → UKIP June 2017 0.44 Labour April 2017 → Conservative June 2017 0.41 Undecided April 2017 → UKIP June 2017 0.32 Plaid Cymru April 2017 → Plaid Cymru June 2017 0.30 SNP April 2017 → Labour June 2017 0.26 Green Party April 2017 → Liberal Democrat June 2017 0.23 Undecided April 2017 → SNP June 2017 0.23 Liberal Democrat April 2017 → Green Party June 2017 0.22 UKIP April 2017 → Green Party June 2017 0.21 Plaid Cymru April 2017 → Labour June 2017 0.17 Conservative April 2017 → Green Party June 2017 0.16 Labour April 2017 → Green Party June 2017 0.12 Green Party April 2017 → Conservative June 2017 0.11 UKIP April 2017 → Liberal Democrat June 2017 0.10 Labour April 2017 → SNP June 2017 0.10 Conservative April 2017 → Plaid Cymru June 2017 0.08 Labour April 2017 → UKIP June 2017 0.07 Undecided April 2017 → Plaid Cymru June 2017 0.06 Green Party April 2017 → SNP June 2017 0.04 Conservative April 2017 → SNP June 2017 0.04 Liberal Democrat April 2017 → SNP June 2017 0.03 SNP April 2017 → Liberal Democrat June 2017 0.02 Green Party April 2017 → UKIP June 2017 0.02 SNP April 2017 → Conservative June 2017 0.02 Liberal Democrat April 2017 → UKIP June 2017 0.02 Plaid Cymru April 2017 → Conservative June 2017 0.02 Liberal Democrat April 2017 → Plaid Cymru June 2017 0.02 Labour April 2017 → Plaid Cymru June 2017 0.02 UKIP April 2017 → Plaid Cymru June 2017 0.02 UKIP April 2017 → SNP June 2017 0.01 Plaid Cymru April 2017 → Liberal Democrat June 2017 0.01 Conservative April 2017 40.03 Conservative June 2017 41.31 Labour April 2017 26.73 Labour June 2017 40.82 Undecided April 2017 12.11 Plaid Cymru April 2017 0.50 Green Party April 2017 2.26 Liberal Democrat April 2017 9.91 SNP April 2017 3.43 UKIP April 2017 5.02 Plaid Cymru June 2017 0.50 Liberal Democrat June 2017 9.09 UKIP June 2017 2.69 SNP June 2017 3.58 Green Party June 2017 2.00 What difference did the campaign make? Source: British Election Study CON LAB UNDECIDED PC GRN LD SNP UKIP CON LAB PC GRN LD SNP UKIP April 2017 June 2017 Labour 2015 → Labour 2017 37.17 Conservative 2015 → Conservative 2017 22.56 Liberal Democrat 2015 → Liberal Democrat 2017 6.48 Conservative 2015 → Labour 2017 5.03 SNP 2015 → SNP 2017 4.26 Conservative 2015 → Liberal Democrat 2017 4.21 Green Party 2015 → Labour 2017 3.47 Liberal Democrat 2015 → Labour 2017 3.36 Labour 2015 → Liberal Democrat 2017 3.25 Labour 2015 → Conservative 2017 1.68 Liberal Democrat 2015 → Conservative 2017 1.07 Green Party 2015 → Green Party 2017 1.02 Green Party 2015 → Liberal Democrat 2017 0.85 SNP 2015 → Labour 2017 0.73 Labour 2015 → Green Party 2017 0.59 Conservative 2015 → Green Party 2017 0.56 UKIP 2015 → Conservative 2017 0.52 UKIP 2015 → Labour 2017 0.45 Plaid Cymru 2015 → Labour 2017 0.42 Plaid Cymru 2015 → Plaid Cymru 2017 0.39 Liberal Democrat 2015 → Green Party 2017 0.29 Labour 2015 → SNP 2017 0.22 UKIP 2015 → Liberal Democrat 2017 0.21 UKIP 2015 → UKIP 2017 0.18 SNP 2015 → Conservative 2017 0.15 Green Party 2015 → SNP 2017 0.12 SNP 2015 → Liberal Democrat 2017 0.11 Conservative 2015 → SNP 2017 0.11 Green Party 2015 → Conservative 2017 0.09 UKIP 2015 → Green Party 2017 0.08 Labour 2015 → Plaid Cymru 2017 0.07 Conservative 2015 → UKIP 2017 0.05 Conservative 2015 → Plaid Cymru 2017 0.05 Liberal Democrat 2015 → SNP 2017 0.05 Liberal Democrat 2015 → Plaid Cymru 2017 0.04 SNP 2015 → Green Party 2017 0.03 Liberal Democrat 2015 → UKIP 2017 0.03 Labour 2015 → UKIP 2017 0.03 Plaid Cymru 2015 → Conservative 2017 0.02 Plaid Cymru 2015 → Liberal Democrat 2017 0.02 Plaid Cymru 2015 → Green Party 2017 0.01 Green Party 2015 → Plaid Cymru 2017 0.01 UKIP 2015 → Plaid Cymru 2017 0.01 Liberal Democrat 2017 15.13 Labour 2015 43.01 Labour 2017 50.63 Conservative 2017 26.09 Conservative 2015 32.57 Green Party 2015 5.56 Plaid Cymru 2015 0.86 UKIP 2015 1.45 SNP 2015 5.28 Liberal Democrat 2015 11.32 Plaid Cymru 2017 0.57 UKIP 2017 0.29 SNP 2017 4.76 Green Party 2017 2.58 Conservative 2015 → Conservative 2017 42.76 Labour 2015 → Labour 2017 14.54 UKIP 2015 → Conservative 2017 14.22 UKIP 2015 → UKIP 2017 4.54 Labour 2015 → Conservative 2017 4.13 UKIP 2015 → Labour 2017 3.88 Conservative 2015 → Labour 2017 2.54 SNP 2015 → SNP 2017 1.80 Liberal Democrat 2015 → Conservative 2017 1.71 Liberal Democrat 2015 → Liberal Democrat 2017 1.64 Liberal Democrat 2015 → Labour 2017 1.07 Conservative 2015 → Liberal Democrat 2017 0.75 UKIP 2015 → Liberal Democrat 2017 0.63 SNP 2015 → Labour 2017 0.61 Green Party 2015 → Labour 2017 0.60 SNP 2015 → Conservative 2017 0.59 Labour 2015 → Liberal Democrat 2017 0.54 Labour 2015 → UKIP 2017 0.54 UKIP 2015 → Green Party 2017 0.45 Conservative 2015 → UKIP 2017 0.38 Green Party 2015 → Green Party 2017 0.28 Green Party 2015 → Conservative 2017 0.24 Labour 2015 → Green Party 2017 0.22 Conservative 2015 → Green Party 2017 0.22 Plaid Cymru 2015 → Plaid Cymru 2017 0.20 Liberal Democrat 2015 → Green Party 2017 0.18 Green Party 2015 → Liberal Democrat 2017 0.11 Liberal Democrat 2015 → UKIP 2017 0.10 UKIP 2015 → Plaid Cymru 2017 0.10 Labour 2015 → SNP 2017 0.08 SNP 2015 → Liberal Democrat 2017 0.06 Conservative 2015 → Plaid Cymru 2017 0.06 Plaid Cymru 2015 → Conservative 2017 0.06 Conservative 2015 → SNP 2017 0.03 Plaid Cymru 2015 → Labour 2017 0.03 Labour 2015 → Plaid Cymru 2017 0.03 SNP 2015 → UKIP 2017 0.02 Liberal Democrat 2015 → Plaid Cymru 2017 0.02 Green Party 2015 → UKIP 2017 0.02 Green Party 2015 → Plaid Cymru 2017 0.01 Conservative 2015 46.74 Conservative 2017 63.71 Labour 2015 20.08 Labour 2017 23.27 Liberal Democrat 2015 4.72 Plaid Cymru 2015 0.29 UKIP 2015 23.82 UKIP 2017 5.60 Green Party 2015 1.26 SNP 2015 3.08 Plaid Cymru 2017 0.42 Green Party 2017 1.35 SNP 2017 1.91 Liberal Democrat 2017 3.73 2015 2017 CON UKIP LAB LD SNP GRN PC CON UKIP LAB LD SNP GRN PC Where the Leave vote went General election choices of Leave voters Source: British Election Study

Despite uncertainty over its position on the single market, Labour was seen as the best bet by those wanting to keep closer ties with Europe.

Not only did it win over a large number of Remainers from the Conservatives, but also from the pro-EU Greens and Lib Dems.

Overall, nearly two-thirds of 2015 Greens went to Labour, as well as about a quarter of Liberal Democrats.

How to say goodbye

One of the reasons Labour did so well among Remainers is that by the time the election was called, the Brexit debate was not so much about Leave or Remain but about how to leave.

The tens of thousands of voters we surveyed were asked whether it was more important for the government to "protect Britain's access to the single market, or to gain full control of immigration".

The results reveal a striking correlation between wanting to control immigration and voting Tory on one hand, and wanting access to the single market and voting Labour or Lib Dem on the other.

For example, the Conservatives lead Labour by more than 40 percentage points among those most in favour of full control of immigration, with Labour having a similar lead among those wanting complete access to the single market.

In effect this meant the Tories were the party of hard Brexit, while Labour was the party of soft Brexit.

The Lib Dems were not the first choice for those favouring a soft Brexit - possibly because of the lingering effects of coalition government, a perception of ineffective leadership and a realisation that they could not win in most seats.

One-way traffic

Although this was a Brexit election, it would be clearly wrong to say the election outcome was determined back in June 2016.

More than at any British election in recent memory, the election campaign really did matter.

Our pre-election survey, carried out in April and May, found that the Conservatives enjoyed a healthy lead over Labour of 41% to 27%.

But by the last three days of the campaign, our daily panel put the two main parties neck and neck.

Overall, 19% of voters switched parties between the April/May survey and the election.

This is similar to the amount of "churn" we saw in 2015, when 17% of voters switched parties, and slightly less than at the 2010 and 2005 elections.

But the significant difference in 2017 was that the flow was overwhelmingly in one direction.

In 2015, Labour and the Conservatives both won about a quarter of these late-switching voters - effectively cancelling each other out.

However, in 2017 Labour won 54% of switchers, compared with 19% for the Conservatives.

Additionally, Labour won more than half of those who hadn't made up their minds before the campaign.

A question of leadership

The main reason that Labour did so well during the campaign is the strong performance of Jeremy Corbyn, especially relative to Theresa May.

At the start of the campaign, Mr Corbyn lagged far behind Mrs May in leader "like scores" - in which voters award a mark out of 10.

Mr Corbyn's score of 3.5 was slightly worse than predecessor Ed Miliband's at a similar point in 2015. However, by the end of the campaign Mr Corbyn had caught up with Mrs May, with both on 4.4.

british_election_party_leaders_liked_16x9 How leader likeability changed during campaign 5.0 4.8 4.6 4.4 4.2 4.0 3.8 3.6 A verage score out of 10 5 May 7 June Source: British Election Study Theresa May Jeremy Corbyn

And although Mrs May was still rated as the leader who would make the best prime minister, the gap had narrowed considerably.

Mr Corbyn's strong performance - or perhaps Mrs May's poor campaign - also meant that Labour closed the gap with the Conservatives when voters were asked which party was best placed to handle the issue they considered the most important for the country.

Over the course of the campaign Labour managed to broaden its appeal, winning over voters who were initially rather lukewarm about Mr Corbyn.

Labour also widened its appeal to more moderate voters on a number of issues, dramatically narrowing the gap with the Conservatives.

During the campaign, previously undecided left-leaning voters and supporters of a soft Brexit were most likely to switch to Labour.

Many of these had previously voted Labour in 2010 and 2015 and so perhaps were "coming home".

While this was undoubtedly the Brexit election, it was also a tale of two leaders and a campaign that mattered.

The Conservative strategy to pin so much on their "strong and stable" leader appears to have been a spectacular mistake which ultimately cost them an overall majority.

About this piece

This analysis piece was commissioned by the BBC from experts working for an outside organisation.

Prof Ed Fieldhouse and Dr Chris Prosser are members of the British Election Study team at the University of Manchester.

The British Election Study is managed by a consortium of the University of Manchester, the University of Oxford and the University of Nottingham, and has carried out studies of voter behaviour at every election for the past 50 years.

Charts produced by Edwin Lowther and Arvin Supriyadi

Edited by Duncan Walker