Modi's Hindu nationalist party was leading in only 58 seats in the 243-seat state assembly compared to 160 for a coalition of rival regional parties, as vote counting continued.
"Had a telephone conversation with Shri @NitishKumar & congratulated him on the victory," Modi said on Twitter of his main opponent, Bihar Chief Minister Nitish Kumar.
Indian-held Kashmir on high alert for Modi's visit
Modi turned the Bihar poll into a key test of his popularity, addressing some 30 campaign rallies and promising voters billions of dollars for development in a state where two thirds lack access to electricity.
The premier's defeat was also a setback to his plans to push major economic reforms through the national parliament where his Bharatiya Janata Party (BJP) lacks a majority.
Assembly elections are important not only because state leaders wield significant power, but because parties gain seats in India's upper house, where the BJP does not have the numbers.
Modi was up against an unlikely alliance of two powerful local leaders, Kumar and his predecessor Lalu Prasad Yadav, who has served time in prison for corruption.
As the contest tightened in recent weeks, the campaign shifted to bitter issues along religious and caste lines which have traditionally dominated the state of 100 million people, more than the population of Germany.
Protestor killed in Indian-held Kashmir after Modi visit
Coalition party workers danced in the street and set off fire crackers in celebration in the state capital Patna. BJP spokesman GVL Narsimha Rao denied the loss was a personal blow for Modi, saying the odds were stacked against their party after regional rivals joined forces.
"This election was loaded against us. It is a defeat of the arithmetic," Rao told India Today TV. "Our PM has delivered even in this election. It is because of his appeal that we managed a creditable performance," Rao said.
The BJP needed a win after suffering a humiliating defeat in February elections for the New Delhi state assembly to a fledgling anti-corruption party.
But exit polls released last week showed the parties running neck and neck, after voting ended on Thursday in the election held in five phases over a month.
Modi, a Hindu nationalist, stormed to power at national polls in May 2014 promising sweeping reforms to revive the faltering economy.
While growth is now purring along at around seven per cent, complaints have been mounting about Modi's failure to nail down major reforms to boost investment and help create jobs for tens of millions of young people.
Some observers say Modi has put off pushing through contentious reforms ahead of the Bihar and other state polls for fear of losing votes, such as a land acquisition bill to make it easier for firms to buy farmland.
Though not on ballot, Narendra Modi is at center of vote in India
The Bihar campaign has been dogged by religious tensions after several Muslims were killed in separate incidents by Hindu mobs who suspected them of stealing or eating cows which Hindus consider sacred.
Analysts said Muslims, who make up 16 per cent of Bihar's population, voted against the BJP, along with lower castes in India's age-old social hierarchy, who sided with traditional allies Kumar and Yadav.
COMMENTS (46)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ