Jeremy Corbyn's election as Labour leader in September 2015, at the age of 66, was one of the biggest upsets in British political history.

A veteran socialist, who had spent 30 years on the back benches championing controversial causes and voting with his conscience, he had been persuaded to stand only because none of his friends on the Labour left had wanted to do it.

"Well, Diane [Abbott] and John [McDonnell) have done it before, so it was my turn," he told the Guardian.

He began the contest as a 200-1 outsider after scraping on to the ballot paper at the last minute, thanks to charity nominations from Labour MPs who had wanted a token left-winger to "broaden the debate". No-one, least of all himself, had expected him to win.

But something about the bearded, unassuming Islington North MP struck a chord with Labour members in a way that his three younger, more polished - and more obviously careerist - rivals did not.

He seemed able to inspire people who had lost faith in Labour during the Tony Blair and Gordon Brown years and bring hope to young activists fired up by his anti-austerity message.

His entry into the contest prompted a surge in people - many to the left of the existing Labour membership - joining the party or paying £3 to become registered supporters, taking advantage of new leadership contest rules.

Image copyright PA Image caption The veteran Labour politician says politics is about fighting for causes one believes in

His election as leader, by a thumping majority, heralded a remarkable revival in fortunes for a brand of left-wing Labour politics that looked to have been consigned to the dustbin of history by Tony Blair.

It also prompted a battle for the soul of the Labour Party between grassroots members who adored Mr Corbyn - and who rallied behind him through a new campaign group, Momentum - and many of the party's MPs, who regarded him as an electoral liability not up to the job of leading an effective opposition.

He has endured fierce criticism from senior party figures and a failed attempt to unseat him through a second leadership election.

Image copyright Getty Images

But he has refused to cave in and now has a chance to fight a general election on his own terms - making the case for a different kind of government in line with the principles he has held, more or less unchanged, since he first entered politics more than 40 years ago.

Party managers are convinced that the more voters see of Mr Corbyn on the campaign trial - rather than reading what they regard as biased and unfair portrayals of him in the media - the more they will warm to him.

They believe his policies, such as renationalising the railways and ending zero hours contracts, are popular with the voting public and the man himself will come across as decent and principled in contrast to his Conservative rivals, although they admit they have a Herculean task on their hands to close the gap before polling day.

Image copyright Getty Images Image caption Laura Alvarez, Mr Corbyn's third wife, applauds his first Labour leadership victory

Jeremy Bernard Corbyn had an impeccable middle-class upbringing.

He spent his early years in the picturesque Wiltshire village of Kington St Michael.

When he was seven, the family moved to a seven-bedroom manor house in the hamlet of Pave Lane, in Shropshire.

The youngest of four boys, he enjoyed an idyllic childhood in what he himself has called a rural "Tory shire".

Who is Jeremy Corbyn?

Image copyright Reuters

Date of birth: 26 May 1949 (age 67)

26 May 1949 (age 67) Job: MP for Islington North since 1983

MP for Islington North since 1983 Education: Briefly at fee-paying preparatory school before a state primary and then, after passing 11-plus, a grammar school, in Newport, Shropshire

Briefly at fee-paying preparatory school before a state primary and then, after passing 11-plus, a grammar school, in Newport, Shropshire Family: Lives with third wife. Has three sons from earlier marriage

Lives with third wife. Has three sons from earlier marriage Hobbies: Running, cycling, cricket, jam-making with fruit grown on his allotment and Arsenal football club. His most unusual hobby is an interest in the history and design of manhole covers. He is also a fluent Spanish speaker, who enjoys Latin American literature

His brother, Piers, now a meteorologist known for denying that climate change is a product of human activity, has described the Corbyn boys as "country bumpkins".

Mr Corbyn disagrees with his brother on climate change, but they remain close.

They both learned their politics at the family dinner table, where left-wing causes and social justice were frequent topics of debate.

Their maths teacher mother, Naomi, and electrical engineer father, David, were peace campaigners who met at a London rally for supporters of Spain's Republicans in the fight against Gen Franco's fascists.

Piers, who would go on to be a well-known squatters leader in 1960s London, was even further to the left than Jeremy.

Both boys joined the local Wrekin Labour Party and the Young Socialists while still at school.

Mr Corbyn had begun his education at the fee-paying preparatory school Castle House, in Newport, Shropshire, before moving into the state sector, after passing his 11-plus.

He was one of only two Labour-supporting boys at Adams Grammar School, in Newport, when his class held a mock election in 1964.

Mr Corbyn left Adams with two A-levels, both at grade E, and an enduring hatred of selective education.

Corbyn in his own words

Image copyright Getty Images

On his frugal lifestyle: "I don't spend a lot of money, I lead a very normal life, I ride a bicycle and I don't have a car."

Speaking to Red Pepper magazine in 2015: "Because I've never had any higher education of any sort, I've never held in awe those who have had it or have a sense of superiority over those who don't. Life is life. Some of the wisest people you meet are sweeping our streets."

Speaking to Channel 4 News: "Are super-rich people actually happy with being super-rich? I would want the super-rich to pay properly their share of the needs of the rest of the community,"

On winning the Beard Liberation Front's Beard of the Year award in 2002: "I started wearing a beard when I was 19 and living in Jamaica; they called me Mr Beardman."

He reportedly split up with his second wife, Claudia, after she insisted on sending their son Ben - now a translator and elite player development officer with Premier League football club Watford - to Queen Elizabeth Grammar School, in Barnet, instead of an Islington comprehensive.

After leaving school, Mr Corbyn spent two years in Jamaica, with Voluntary Service Overseas, something he has described as an "amazing" experience.

Back in the UK, he threw himself into trade union activism, initially with now long defunct National Union of Tailors and Garment Makers.

Image copyright PA Image caption The late Tony Benn was a key influence on Corbyn's politics

He started a course in Trade Union Studies at North London Polytechnic but left after a series of arguments with his tutors over the curriculum.

"He probably knew more than them," Piers told the Sun.

A successful career as a trade union organiser followed, with the Amalgamated Engineering and Electrical Union (AEEU) and then the National Union of Public Employees (NUPE).

But his real passion was for Labour Party politics - and in 1974 he was elected to Haringey District Council, in north London.

In the same year he married fellow Labour councillor, Jane Chapman, a university lecturer.

Ms Chapman says she married Mr Corbyn for his "honesty" and "principles" but she soon grew weary of his intense focus on politics.

"Politics became our life. He was out most evenings because when we weren't at meetings he would go to the Labour headquarters, and do photocopying - in those days you couldn't print because there were no computers,' she told The Mail on Sunday.

What others say

Former Labour MP Chris Mullin, speaking to the BBC's Panorama in 2015: "Jeremy is a saintly figure of enormous personal integrity. He is a man who lives his life according to his beliefs."

Guardian columnist Polly Toynbee, on the day the general election was called: "Was ever there a more crassly inept politician than Jeremy Corbyn, whose every impulse is to make the wrong call on everything? It's not excitingly flamboyant red radicalism that has done for Labour, but his sluggish incompetence at the absolute basics of leadership,"

The Morning Star, February 2017: "He has been bullied, betrayed and ridiculed, and yet he carries on with the same grace and care he always shows to others - however objectionable their behaviour and treatment of him might be."

Former shadow foreign secretary Hilary Benn (pictured) in June 2016: "He is a good and decent man, but he is not a leader,"

They shared a love of animals, they had a tabby cat called Harold Wilson, and enjoyed camping holidays together in Europe on Mr Corbyn's motorbike.

But fun was in short supply at home, recalls Ms Chapman, who remains in touch with Mr Corbyn and backed his party leadership bid.

During their five years together he had never once taken her to dinner, she told the Daily Mail, preferring instead to "grab a can of beans and eat it straight from the can" to save time.

In 1987, Mr Corbyn married Claudia Bracchita, a Chilean exile, with whom he had three sons.

The youngest, Tommy, was born while Mr Corbyn was talking to Nupe members elsewhere in the same hospital.

His second son, Sebastian, worked on his leadership campaign and is now shadow chancellor John McDonnell's chief of staff.

Image copyright PA Image caption Mr Corbyn is a long standing supporter of Irish republicanism

The couple separated in 1999, but remained on good terms.

Mr Corbyn got married for a third time in 2012, to Mexican human rights lawyer and fair trade coffee importer Laura Alvarez, who is two decades his junior.

In the bitter internal warfare that split Labour in the late 1970s and early 80s, Mr Corbyn was firmly on the side of the left.

A Labour man to his fingertips - he was no Militant "entryist" trying to infiltrate the party by stealth - he nevertheless found common cause with former Trotskyists and joined them in their battle to push the party to the left.

He became a disciple of Tony Benn, sharing his mentor's brand of democratic socialism, with its belief in worker controlled industries and state planning of the economy, as well as Benn's commitment to unilateral nuclear disarmament and a united Ireland.

Corbyn's causes

Image copyright PA

Here is just a small selection of the campaigns Jeremy Corbyn has been involved with over the past 50 years.

Nuclear disarmament: Joined CND as a schoolboy in 1966

Irish republicanism: Organised Sinn Fein leader Gerry Adams's visit to the Commons in 1983. Once employed Irish republican dissident Ronan Bennett as a member of staff at Westminster

Miners' strike: Invited striking miners into Commons gallery in 1985, who were expelled for shouting: "Coal not dole"

Anti-apartheid: Served on the National Executive of the Anti-Apartheid Movement, and was arrested in 1984 for protesting outside South Africa House

Palestinian solidarity: A member of the Palestine Solidarity Campaign and campaigns regularly against the conflict in Gaza

Miscarriages of justice: Worked on behalf of the Guildford Four and Birmingham Six, who were eventually found to be have been wrongly convicted of IRA bombings in England in the mid-1970s

Animal rights: Joined the League Against Cruel Sports at school, became a vegetarian at 20 after working on a pig farm

Iraq War: Chaired the Stop the War coalition

Gay rights: Spoke out in 1983 on a "no socialism without gay liberation" platform and continued to campaign for lesbian, gay, bisexual and transgender rights

Mr Corbyn was never seen as a great orator like Tony Benn, or a firebrand like miners' leader Arthur Scargill, but he worked tirelessly behind the scenes, his trousers stained with purple ink from the copying machines that produced the pamphlets and newspapers that were the lifeblood of the British left in the pre-internet era.

He wrote for the London Labour Briefing newspaper, which helped propel Ken Livingstone to power on the Greater London Council, although he denies reports that he was a member of its editorial board.

He was elected to Parliament in 1983, to represent his home patch of Islington North, a seat he has held ever since and where he has increased his majority from 5,600 to 21,000.

The Bennite faction that Mr Corbyn belonged to was already in retreat, following their leader's failure to capture the deputy leadership of the party in 1981.

'Modernisation'

After fighting and losing the 1983 election on arguably the most left-wing manifesto it had ever put before the British public, with its commitment to renationalising the utilities just privatised by the Thatcher government, pulling out of the EU and nuclear disarmament, Labour began the painful process of "modernisation" that led to the birth of New Labour.

And Mr Corbyn would spend the next 32 years on the back benches fighting a rearguard action against his party's abandonment of the radical policies and values contained in the 1983 manifesto in the name of electability, under Neil Kinnock, John Smith and then Tony Blair.

Leaders' profiles

Mr Corbyn might have hailed from the same north London district as Mr Blair and entered Parliament in the same year, but that is where the similarity ended.

He abhorred Mr Blair's embrace of free market economics and did his best to be a thorn in the younger man's side throughout his time in Downing Street, although Mr Blair's large majorities ensured the damage was barely noticeable.

He would always vote with his conscience, rather than be dictated to by the party whips.

It earned him the accolade of being Labour's most rebellious MP, defying the party managers more than 500 times.

It also meant he and his allies became increasingly isolated, with their views and interventions ignored by the national press and most of their colleagues on the Labour benches.

Image copyright PA Image caption Mr Corbyn has been a stalwart of the British left for more than 40 years

Image copyright PA Image caption Campaigning for a united Ireland in 1984

Internationalist in outlook, Mr Corbyn and his comrades - unlike their modernising colleagues, they would use the term without irony - would proclaim solidarity with socialist campaigns and governments in places such as Cuba, Chile, Nicaragua and El Salvador and attack US "imperialism", which, in Mr Corbyn's view, enslaved the Latin American world.

He incurred the wrath of the Labour leadership early in his career, when he invited two former IRA prisoners to speak at Westminster, two weeks after the Brighton bomb that had nearly killed Margaret Thatcher and her cabinet.

Later on, it would be his willingness to share platforms with representatives of Hamas and Hezbollah that would put him at the centre of controversy.

When challenged, he insists he does not share their views but that peace will never be achieved without talking to all sides.

He may have been largely sidelined in the House of Commons, respected but too much of a known quantity to have an impact, but Mr Corbyn's stature and profile outside Parliament continued to grow.

He chaired the Stop the War Coalition and became a leading figure in the anti-austerity movement, which began to attract large crowds of young activists eager for something to believe in and to take the fight to then Prime Minister David Cameron.

Still, no-one gave Mr Corbyn a prayer when he entered the contest to succeed Ed Miliband as Labour leader.

But a change in the rules brought in by Mr Miliband, amid claims the trade unions had too much influence, meant it was a very different electorate to the one that had chosen previous Labour leaders.

Under the old electoral college system, MPs and party members each had one-third of votes and trade unions the remainder.

With the new "one-person-one-vote" system, MPs and trade unions had no more say in the outcome than ordinary party members or people who had joined up as registered Labour supporters for £3.

Thousands of new members and supporters, many of whom had turned their back on Labour during the Blair-Brown years, flocked to Mr Corbyn's rallies and spread his message on social media, using the hashtag #Jezwecan.

Image copyright Reuters Image caption Mr Corbyn's relationship with the media has been a turbulent one

If the veteran Labour MP was stunned by his sudden elevation to rock star status, among new and returning Labour supporters, he rarely showed it.

He carried on, just as he always had, railing against inequality, talking about hope, promising to renationalise industries and tax the rich, and wearing the same white, open-necked shirt with pens sticking out of the top pocket.

Image copyright PA Image caption The Labour leader sought to bring a new approach to Prime Minister's Questions

After his surprise victory, many "moderate" shadow cabinet members returned to the back benches rather than serve under him, but he was able to put together a top team that reflected a broad range of opinion within the party.

He sought to bring a new approach to leadership, adopting a less confrontational and more conversational tone at Prime Minister's Questions, with crowdsourced questions from members of the public.

He generally avoided soundbites and photo opportunities - to the exasperation of what his supporters call the "mainstream media" and the derision of some commentators.

Leadership challenge

The coalition behind Mr Corbyn held together for nine months, despite growing discontent among Labour MPs who had never wanted him as leader and could not accept either his style of leadership or his policies.

They despaired at what they saw as his lacklustre performances at the despatch box, arguing that he missed too many open goals and was not landing enough blows on the government.

The EU referendum brought things to a head. Mr Corbyn, who had been a Eurosceptic as a backbencher, was accused of mounting a half-hearted campaign to keep Britain in the EU and of not appearing to care too much that his side had lost.

Labour MPs, some of whom had been plotting to topple Mr Corbyn at some point, saw this as the chance to make their move to try to make him stand down, amid fears they would be wiped out at the snap election they expected to follow the referendum, with him as leader.

Image copyright PA Image caption Owen Smith said his rival was unelectable, but Mr Corbyn trounced him at the polls

He faced a mass walkout from the shadow cabinet and then a vote of no confidence, which he lost by 172 votes to 40, as Labour MPs - enemies and previously loyal shadow ministers alike - urged him to quit.

He refused to budge, pointing to the huge mandate he had received from Labour members and arguing that he had done better than many had expected in the electoral tests he had faced since becoming leader.

MPs selected Owen Smith, a former member of his shadow cabinet who claimed to share the same left wing values, to take him on in another leadership election.

Image copyright PA Image caption The Labour leader drew big crowds during his second leadership election

So Jeremy Corbyn, the reluctant leader who had to be persuaded to stand in 2015, now found himself fighting to keep a position he never expected to hold, this time as favourite rather than as outsider.

As was the case a year earlier, thousands of people flocked to hear Mr Corbyn speak at rallies across the country - 10,000 turned up at a single event in Liverpool - as he sought to tap directly into grassroots support for his message as a counterweight to the perceived hostility of the "mainstream media".

His re-election strengthened his position, with some of his critics showing a willingness to work with him in the shadow cabinet, although many Labour MPs were privately in despair at the prospect of fighting the next election, which was scheduled for 2020, with him as leader.

Labour's defeat in the Copeland by-election - a seat it had held for more than 80 years - was seen by critics as a further sign that the party was headed for oblivion or some kind of split.

Image copyright EPA Image caption Mr Corbyn hits the road for the third time in three years

Unite union leader Len McCluskey - one of Mr Corbyn's most powerful allies - said he should be "given a chance" and allowed 15 months to prove he could turn around opinion polls, which were giving the Conservatives a 20 point lead.

A month later, Prime Minister Theresa May surprised everyone by announcing she wanted a general election on 8 June 2017.

Mr Corbyn could have blocked the snap election - by ordering his MPs to vote against it in the Commons - but instead he welcomed it as a chance to "give the British people the chance to vote for a government that will put the interests of the majority first".

It quickly became clear that he intended to fight the election in his own way - as an "anti-establishment" candidate, dedicated to overturning the "rigged" system that favoured elites over ordinary working people.

When quizzed about the seemingly insurmountable odds of him winning power, he reminded people of the 2015 Labour leadership contest - the pundits and pollsters had not given him a prayer then but he had proved them all wrong.

Illustration by Gerry Fletcher