Three days before Uttar Pradesh went to polls on 11 February, the president of BJP’s UP unit landed on a small field in Saharanpur’s Gangoh constituency.

Keshav Prasad Maurya belonged to a backward community. He was a product of the Sangh, a functionary of the Vishwa Hindu Parishad (VHP), before he contested elections for the UP assembly in 2012. In 2014, he rode on the Modi hawa, and became an MP from Phulpur – which was once Jawaharlal Nehru’s constituency. In early 2016, the BJP had made him state chief, in an obvious bid to woo the backward communities.

As he stepped out of the helicopter, a crowd rushed on to the field to greet him. Maurya got into an SUV, the trademark of all North Indian politicians, to get to the venue of the public meeting.

The next car was packed with a dozen people.

Om Pal Singh Saini introduced himself as the president of the All India Saini Seva Sangh. This was a Saini-dominated area, he said, with a tinge of pride. Sainis are categorised as OBCs in UP, and see themselves as a part of a larger community of Saini–Kashyap–Kuswaha–Mauryas, to which the BJP leader belonged.

“This time, the BJP has shown us respect. The entire samaj is with the party, because Mauryaji will become chief minister.” The community, he said, had swung between various parties in the past. But in the 2014 elections, it overwhelmingly went with Narendra Modi. Ever since Maurya was made the state president of the party in 2016, it had made up its mind to stick to the lotus.

Bhajapa hamari party hai ab. BJP is our party now. The PM is ours. The state president is ours. The district president is ours. We finally have a political voice,” said Saini.

It was left unsaid, but “ours” meant that the prime minister belonged to the “pichda”, backward, community; Maurya was from his own wider caste group; the district president was a Kashyap.

Three small farmers had come to the rally to listen to the state party president.

One of them was a Gujjar, Ram Singh. He traced back his family’s political affiliations to Charan Singh, former prime minister, and one of North India’s most respected kisan netas, who had carved out a coalition of backward castes and Muslims, based on their peasant identity. “My father was with Charan Singh. I got attracted to the Ram Janmabhoomi Andolan and came to the BJP. After Kalyan Singh left the BJP, I voted for others. But in 2014, I returned to the party.”

Kalyan Singh was the BJP chief minister in the 1990s. A Lodh, he had been able to rally OBCs behind the party. But he steadily got marginalised in the party and left in 2009. He subsequently returned to the party and campaigned for Modi in 2014.

“Both the Congress and Samajwadi Party only do the politics of one community. They are communal. Congress can see only one community, BSP can also see only one community – see Mayawati keeps saying I have given ninety-seven tickets, and we all know about SP. It gave the family of Akhlaq [the man who was killed in Dadri over allegations of consuming beef ] one crore,” said Ram Singh.

Without uttering the word Muslim, he had made it clear what he meant.

The BJP, Singh added, was a nationalist, rashtravaadi, party. But wasn’t the Congress a nationalist party as well? After all, it is the party that brought India freedom. “Congress is a national, rashtriya, party, but it does not have a nationalist, rashtravaadi, mindset.”

Om Prakash Saini was thrilled with the representation and respect offered by the BJP to his community. Ram Singh was attracted by what he saw as the “nationalist” rather than “communal” outlook. Together, these sentiments would be the game changer in the UP elections.

The voices from the ground fit in exactly with the scheme laid at the top by party strategists, which had three broad components – changes in the party’s organisational structure to make it more inclusive; reformulation of its messaging, so that backward communities felt both a sense of victimhood and a sense of emancipation; and alliances with parties with a base among these communities, despite the BJP’s overwhelming dominance.

Narendra Modi has turned himself into a leader of the poor while retaining the support of the better-off.

In the background, Amit Shah is slowly transforming the BJP into a party of the less privileged castes, while retaining the support of the privileged. In the process, the BJP is moving from being a relatively exclusivist Hindu party to becoming an inclusive Hindu party. By identifying the most dominant political caste (which is not necessarily synonymous with the most dominant social caste) in a particular setting, and mobilising the less dominant against them, Shah is weaving together unprecedented social coalitions. This remarkable experiment in social engineering lies at the heart of the BJP’s political success. And when it fails to carve out broad-based social coalitions, when it is seen as a party of merely the privileged, it collapses.

After taking over as party chief, Amit Shah had to face assembly elections in Maharashtra and Haryana. In the absence of a strong organisation, he had to get the arithmetic right.

He decided to focus on a strategy of political mobilisation against “privileged castes”. This may seem counter-intuitive at first, for the party is associated with those castes which have benefited from the social structure and remain at the top of the hierarchy. But here, the party has cleverly made a distinction between the traditionally dominant castes in the social hierarchy and the politically privileged castes.

The calculation is simple. All Indian states are plural in their composition. With the rise of Mandal politics, assertion of OBCs and their mobilisation, the more numerically and socially dominant of these groups – from peasant backgrounds – have also become politically dominant. But precisely because of that, a range of other castes – both the traditionally powerful and the more marginalised – feel alienated. And thus, the trick is to mobilise these castes and construct a coalition against the dominant caste – which is, in the post-Mandal era, usually the numerically largest middle caste of the particular setting.

In Maharashtra, where the politically dominant caste is the Marathas, the BJP had, since the 1990s, adopted a pro-OBC strategy.

It had promoted leaders from the backward communities. Along with this, following the alliance with Shiv Sena and the sharpened communal polarisation, it had come to power in 1995. But for fifteen years, it had been out in the opposition. In the 2014 Lok Sabha polls, the Modi appeal helped the party mount a strong comeback and it won 42 of the 48 seats.

But the assembly election required more careful social engineering. The BJP stitched together an alliance of upper castes, OBCs and, to a lesser extent, Dalits. The BJP did get a fraction of Maratha votes, and given they are over 30 per cent of the state population, it is not entirely easy to displace them. But its core strength came from non-Maratha castes. Since there are over 200 OBC groups, and the largest of them is less than 5 per cent, this required ground-level management. The nature of the mandate was manifested in the chief ministerial pick of the party. It appointed a Brahman, Devendra Fadnavis.

Suhas Palshikar, a Pune-based political scientist, notes that the BJP won 53 of the 100 urban seats, with a 35 per cent vote share; it also, according to a post-poll survey, got 52 per cent of the upper-caste and 38 per cent of the OBC vote. ‘The results of the 2014 election have firmly removed the Maratha elite from state power.’

In Haryana too, in the assembly elections, the BJP did the unthinkable.

The state, associated with Jat political dominance, saw the party construct a coalition of non-Jat communities. This meant bringing together upper castes, OBCs like Yadavs, Gujjars and Sainis, and Dalits. It did not entirely give up on Jats, and appointed a senior community leader of the state, Chaudhary Birendra Singh, in the Union cabinet. But its focus was on the less dominant.

In north, east and south Haryana, the BJP did well, slipping behind others only in the Jat-dominated western part of the state. The post-poll survey by the Centre for the Study of Developing Societies suggested that the BJP got 47 per cent of the Brahman votes, 55 per cent among other upper castes and 40 per cent of the OBC votes. The party, from a measly 4 seats in 2009, shot up to 47 seats in an assembly of 90, forming the government for the first time on its own. And here too, it appointed a non-Jat, Manohar Lal Khattar, the chief minister.

Amit Shah was getting his social arithmetic right. But he would confront his biggest challenge, and failure, in the complex social landscape of Bihar the next year.

Excerpted with permission from How The BJP Wins: Inside India’s Greatest Election Machine, Prashant Jha, Juggernaut.