Like a Gujarati thali, the 2017 Gujarat assembly election had a little bit for everyone. The BJP retained Gujarat for the sixth successive time, beating strong anti-incumbency and a caste coalition of Dalits, Patidars and OBCs led by Jignesh Mevani, Hardik Patel and Alpesh Thakor.

The Congress increased its seat tally to its highest level in decades, allowing newly coronated president Rahul Gandhi to take legitimate credit for a hard-fought campaign. Prime Minister Narendra Modi showed again that, despite a mini-gathbandhan of Congress and caste leaders ranged against him, he could pull the chestnuts out of the fire when it mattered.

More critically, how will the Gujarat election outcome affect the eight assembly polls due in 2018? Four northeastern states – Meghalaya, Tripura, Nagaland and Mizoram – will hold elections next year. Four big states – Karnataka, Madhya Pradesh, Rajasthan and Chhattisgarh – also go to the polls in 2018. Karnataka is first up in April 2018. The BJP will be wary about its chances of unseating the Congress. Chief Minister Siddaramaiah has in recent months consolidated his position. Six months ago, the BJP was confident of winning Karnataka and reducing the Congress to just one large state, Punjab. That no longer looks a certainty. Siddaramaiah has played the Lingayat card, claiming that the community is not a part of Hinduism. BS Yeddyurappa, the BJP’s main campaigner and a Lingayat, will have to pull out all the stops to win a state where the JD(S), though not a major force, could forge a decisive alliance with the Congress.

A much bigger problem though awaits the BJP in December 2018 when Rajasthan, Madhya Pradesh and Chhattisgarh hold elections. Rajasthan is the most vulnerable of the three. Chief Minister Vasundhara Raje is an unpopular leader. After a recent visit to the state, one colleague said he had met almost no one in Rajasthan who was likely to vote for Raje. The chief minister’s strained relationship with BJP party president Amit Shah is another complication. Without close synergies between Raje and Shah, running an effective campaign in Rajasthan will be difficult. The Congress could meanwhile benefit from Sachin Pilot’s OBC thrust in Rajasthan. It has a realistic chance of winning back from the NDA another big state after Punjab.

Madhya Pradesh suffers from strong anti-incumbency and a backlash from the Vyapam scam. Chief Minister Shivraj Singh Chouhan remains popular but recent by-election defeats in key constituencies have set alarm bells ringing. Jyotiraditya Scindia will lead the Congress campaign along with veteran leader Kamal Nath. In the 2014 Lok Sabha election, the two were the only Congress leaders who won their seats in Madhya Pradesh amidst the nationwide Modi tsunami.

Like Madhya Pradesh, Chhattisgarh too could be hit by anti-incumbency. In a binary contest with the Congress, as the Gujarat poll has shown, the Congress can exploit voter fatigue with an incumbent. Chief Minister Raman Singh has been stolid rather than an inspirational leader though, unlike Pilot in Rajasthan and Scindia in Madhya Pradesh, the Congress in Chhattisgarh lacks a charismatic leader.

More worrying for the BJP is what the Gujarat election result portends for the 2019 Lok Sabha election. The Congress has shown that it retains the ability to be a robust opponent. Even a relatively small coalition with the Patidars and other caste combinations was enough to run the BJP close in Gujarat. If Modi hadn’t campaigned as vigorously as he did in the state, the BJP could have come perilously close to falling below the 92-seat mark and ceding its majority for the first time since 1995. While Modi’s vote-catching popularity has not ebbed from the high of 2014, the BJP’s on-ground performance has clearly fallen short. Instead of winning the 150 seats Shah had proclaimed, the party scrambled to a slender majority.

The biggest worry for the BJP though is the emergence of Rahul Gandhi as a major future electoral threat. Rahul campaigned tirelessly in Gujarat, rarely losing focus. He temple-hopped to assert his Hindu roots, realising that in sharply polarised Gujarat being seen as a Muslim appeaser would be an electoral disaster. Rahul’s social media messaging has also become sharper with a young new team. No longer can the BJP or its supporters dismiss Rahul as a lightweight.

In the end, victory margins do matter. They can influence voting patterns in future elections. They can energise the loser and chasten the winner. By winning the Gujarat poll by a margin narrower than most exit polls had predicted, the BJP has shown vulnerability. In Bihar in 2015, it lost because of the Congress-JD(U)-RJD mahagathbandhan. In Gujarat, it has scraped through after being given a fright by the caste coalition the Congress cobbled together.

Opposition leaders will learn from the BJP’s underwhelming performance in Gujarat. Coalitions, where possible, are now the likely route in most future state and general elections. For Modi, Gujarat has several lessons. One, he must build a stronger second line of leadership. Two, the BJP must rebuild its NDA coalition: it suffers from neglect and that could cause problems in 2019. Three, the prime minister should re-focus on development and governance. Establish a Lokpal, revive the sclerotic Right To Information (RTI) ecosystem, and overhaul the bureaucracy. Time is running out.

The writer is author of The New Clash of Civilizations:How The Contest Between America, China, India and Islam Will Shape Our Century