The leaders of two anti-establishment parties have each claimed they have the right to govern Italy, after voters in Europe’s fourth-largest economy did not return a majority to any single party.
The Eurosceptic, populist Five Star Movement was the biggest single party with a third of the vote.
But the anti-immigrant League said it had been endorsed to run the country as part of a centre-right alliance.
Forming a government could take weeks of negotiation and coalition-building.
Former Prime Minister Matteo Renzi has resigned as leader of the governing centre-left Democratic Party, which performed poorly, taking less than 20% of the vote.
He said the party would not join a coalition with “anti-system forces” and would go into opposition instead.
An alliance between the far-right League and ex-Prime Minister Silvio Berlusconi’s Forza Italia party is set to win the most seats in the lower house of parliament, but the League has emerged as the senior partner.
Matteo Salvini, the 44-year-old leader of the League, said at a press conference that he intended to speak to other parties to gain a parliamentary majority.
Five Star leader Luigi Di Maio, 31, announced that his party was also open to coalition talks with other parties – this despite the party having stated the contrary in the runup to the vote.
The gains for populists represent a political earthquake that will send shockwaves to the EU in Brussels, BBC Europe editor Katya Adler says.
A coalition between Five Star and the League would be a “nightmare result” for the EU, our correspondent adds. However, Mr Salvini told reporters he would not go into coalition with Five Star.
Results showed that the League conquered broad swathes of Italy’s north, while Five Star saw its strongest show of support in the south.
The centre-left coalition, dominated by the Democratic Party, was punished in traditional strongholds including Emilia-Romagna, the northern region home to the city of Bologna.
Voter turnout was estimated at 73% on Monday morning, according to interior ministry figures.
What does the result mean?
Though no party will be able to rule alone based on latest results, the surge of support for populist parties has been compared with Brexit and the election of Donald Trump in the US.
The right-wing alliance, which also includes the far-right Brothers of Italy, is tipped to get 248-268 seats – below the 316 needed for a majority.
But Five Star is expected to emerge as the largest single party in Italy’s lower house, with 216-236 seats.
The party was founded in 2009 by comedian Beppe Grillo, who denounced cronyism in Italian politics. It has captured new voters in the poorer regions of southern Italy, feeding off anger over institutional corruption, economic hardship and immigration.
Italian voters appear to have abandoned Mr Renzi’s Democratic Party because of dissatisfaction over these issues, and the centre-left coalition is projected to come a distant third, with an estimated 107-127 seats.
Immigration and the economy have been two of the key issues for voters during the election.
More than 600,000 migrants have travelled from Libya to reach Italy since 2013, which has upset many Italians.
The state of the economy was also at the centre of the debates. In 2016, some 18 million people were at risk of poverty, and unemployment is currently at 11%.
Results from the vote for Italy’s Senate, the upper house of parliament, also favoured populists and parties of the right. Five Star performed better than anticipated and was forecast to take the most seats – around 102-122 – but miss out on a majority.
The right-wing coalition is predicted to get 118-150 seats in the upper house, and the Democratic Party 42-54.
Advantage Five Star – but what happens next?
By James Reynolds BBC News, Milan
We still don’t know who the winner will be. But in this opening act, Five Star has gained a certain advantage. Its message clearly resonated with young people searching for jobs, and with voters in the poorer south of the country.
The movement made a big point of running alone in this election. By contrast, other major parties teamed up into electoral alliances. But the feature which gave the party its strength – its independence – may now become its weakness. In order to form a government, Five Star must find coalition partners. Its inexperience in working with others may be a disadvantage in the practical business of coalition-building.
So, which way will Five Star seek to turn? There is some speculation that the movement may seek a coalition with the League.
Both parties have criticised Italy’s relationship with the European Union, although neither campaigns to leave the bloc. A potential alliance between the two would be viewed with some degree of worry in Brussels.
Berlusconi’s party outshone by allies
The vote comes as a blow to Silvio Berlusconi, 81, whose party led the right-wing coalition. But now Matteo Salvini has laid claim to that role.
He has promised to deport hundreds of thousands of migrants and spoken of the “danger” of Islam.
“My first words: THANK YOU,” tweeted Mr Salvini as projections rolled in.
In any case Mr Berlusconi cannot hold public office himself until next year because of a tax fraud conviction.
Who is Matteo Salvini?
The leader of the League is a proud Eurosceptic, who has praised Brexit and voiced opposition to the euro in the past.
“It’s a fantastic victory which fills us with pride,” said Mr Salvini on Monday as results came in.
He claimed Italian voters had “made a step forward to be free from the cages and ties that are bringing back hunger and insecurity in Europe”.
In the same speech, Mr Salvini repeated his stance that the euro is bad for Italy.
“It’s a wrong currency and a wrong choice,” he said.
How Italy’s press reacted – BBC Monitoring
La Stampa (centre-left): Di Maio wins, Italy is ungovernable
La Repubblica (centre-left): Italy belongs to the Five Star Movement and the League; the Democratic Party is knocked out, Renzi on his way out
Libero (centre-right): A chaotic government of amateurs – anger and confusion at the polls: From bad to worse
Il fatto quotidiano (populist): The Five Star Movement soars, Renzi crashes, Salvini wipes out Berlusconi: Everything changes