Leaders from Modi's Bharatiya Janata Party said the party's victory in Uttar Pradesh, India's largest state, would boost Modi's chances of winning another term as India's prime minister in 2019 elections.
The Election Commission said the BJP won 311 out of 403 seats in Uttar Pradesh's legislature. The party's president, Amit Shah, described it as "a historic verdict."
In another northern state, Uttarakhand, the BJP won 56 of 70 seats and was leading in one other constituency, wresting power from the Congress party, the main opposition at the national level. The Congress party lost power by winning only 11 seats.
The elections were held in five states in February and early March, but the votes were not tallied until Saturday.
Modi tweeted: "Am overjoyed that BJP has received unprecedented support from all sections of society. Huge support from the youth is gladdening."
The Congress party had a face-saving win in Punjab state, where it captured 77 of 117 seats, unseating the governing alliance of the BJP and a powerful regional group, the Akali Dal.
Both the BJP and the Congress party failed to win a majority of seats in western Goa state and northeastern Manipur state, according to the Election Commission. The Congress was ahead in the two states. The parties will seek the support of regional groups to stitch governing alliances.
Rahul Gandhi, the Congress party vice president, seems to have failed to make any impact for his party in Uttar Pradesh, located in the Hindi heartland, with his party winning five seats and leading in another two constituencies. The party's ally, the Samajwadi Party, had won 33 seats and was leading in 16 other voting districts.
Sandeep Dikshit, a Congress party leader, said that "it will be unfair to blame the party's debacle entirely on Rahul Gandhi."
The victory will come as a big morale-booster for Modi, who had campaigned extensively in the region for his party's nominees.
"The BJP has reached new heights in Uttarakhand and Uttar Pradesh states and changed the political picture of the country," India's home minister, Rajnath Singh, said in New Delhi. The party will be returning to power in Uttar Pradesh after 14 years.
Kapil Sibal, a senior Congress party leader, conceded that "No doubt, it's an astounding victory for the BJP."
Modi's party appears to have successfully forged a coalition of upper, middle-ranking and lower castes in Uttar Pradesh. "The elections prove that the BJP was able to break caste and class barriers," social scientist P. Kumar of the Giri Institute of Development Studies said in Lucknow, the state capital.
Modi continued a winning run in the state for the BJP, which won 71 of Uttar Pradesh's 80 seats in India's Parliament in 2014 national elections.
The Congress party and other BJP rivals vainly hoped that voters would punish Modi's government for its decision to demonetize the country's highest-value currency bills in November, which brought immense economic hardships, especially to the poor.
Modi called India's massive demonetization drive, which withdrew 86 percent of the country's currency bills from the system, to cleanse the system of tax evasion and corruption. Banks and ATMs witnessed massive lines of people for months. ATMs were not refilled for days and banks ran out of cash within a few hours of opening.
The government was able to tide over the problem as voting started last month.
"People have strongly supported Modi on the demonetization issue," said Shah, the BJP president, adding that they believed it was a step taken to recover unaccounted money hoarded by the rich.
A majority of Indians earn and spend in cash, either due to habit or because they're too poor to have access to banks.
Since taking office in May 2014, Modi's government has been pumping funds into boosting education, while increasing spending on roads, irrigation and other infrastructure. It has also been reforming India's complicated tax regime.