NEW DELHI — On Tuesday, Prime Minister Narendra Modi’s Bharatiya Janata Party suffered a major defeat in elections for the Delhi state legislature. Amit Shah, the prime minister’s confidante and the country’s home minister, led a highly divisive and sectarian campaign foregrounding Hindu nationalism and demonizing the city’s Muslims, and tried to paint the opposition Aam Aadmi Party and its leaders as treasonous.

Yet out of Delhi’s 70 seats, Mr. Modi and Mr. Shah’s B.J.P. won a mere eight seats, and the A.A.P., led by Arvind Kejriwal, who has been the chief minister of Delhi since 2015, won 62.

Mr. Kejriwal, an anti-graft activist turned politician, focused the electoral campaign of his party on his record of governance — the significant improvement he made to the delivery of services in public hospitals, the quality of education and infrastructure in schools, and the cost of electricity in Delhi.

Delhi chose Mr. Kejriwal for his performance as chief minister. While the B.J.P. plastered Mr. Modi’s face across the city, it did not offer any candidates for the Delhi state government who were more impressive or convincing than Mr. Kejriwal and his team.