Israeli elections last night produced the tightest of races with early television exit polls putting Tzipi Livni, the centrist foreign minister, narrowly ahead of the rightwing opposition Likud leader, Binyamin Netanyahu.

Polls from three main television stations, broadcast moments after voting closed last night, all put Livni's Kadima party ahead by two seats, but they also predicted that the rightwing parties had fared best overall. Livni was predicted to have won either 29 or 30 seats in the 120-seat Knesset.

Avigdor Lieberman, the far-right leader, came in third, ahead of Ehud Barak, the Labour leader and defence minister, whose party was headed for one of its worst election results.

If the exit polls are accurate, and in the past they have not always been reliable, it suggests that there may be a long, drawn out period of negotiations to form a coalition. Even if Livni emerges with the largest party, she may not become prime minister if the rightwing parties together can muster a larger coalition.

If the final result is this close it makes Lieberman a kingmaker. If Livni can draw him into a coalition she might hope to find a majority. However, Netanyahu's Likud sounded bullish.

"The person who will form the government is the person who gets 61 votes," said Dan Meridor of Likud. "I see no way that Livni can do this."

Both Netanyahu and Livni cast their votes early and urged Israel's 5.3 million eligible voters to go to the polls for what was one of the closest election races in recent years.

"I have just done what I want every citizen in Israel to do: first of all to get out of the house, rain or no rain, cold or hot, go out, go to the polling station, go into the booth, close your eyes, and vote," Livni announced, after casting her ballot in Tel Aviv.

Netanyahu voted in Jerusalem and then travelled to the southern city of Be'er Sheva, to emphasis his security credentials in a city hit by rockets during last month's war in Gaza.

"I will do everything so that our enemies won't provoke us, won't think we're weak, won't rain down ... their rockets," he said.

Under Israel's proportional representation system no one party is likely to win a majority, meaning that weeks of negotiation will now follow to form a coalition government.

Next week the Israeli president, Shimon Peres, will call on the leader of the party he thinks most likely to be able to form a coalition, regardless of whether that is the largest party, and give him or her 42 days to complete the task.

These early elections were triggered last autumn when the current prime minister, Ehud Olmert, said he would resign in the wake of several corruption investigations. He will stay on as caretaker prime minister until the new cabinet is formed.

For months leading up to the election Netanyahu had been comfortably ahead in the polls, but his lead narrowed sharply in the final days. In part the rise of the far-right leader Lieberman took votes away from the Likud party, although the rightwing as a whole looked set to dominate. But many voters said yesterday they had been undecided until they walked into the polling booth.

"I am by instinct a leftist, but I think the leftists failed completely and it is time to recognise that we need really to be strong and somewhat aggressive in the way in which we live or we have no hope," said Herb Alexander, a psychology professor who cast his vote in Talbiyah, in west Jerusalem.

Gil Erlich, 28, a psychologist, had voted Labour in the past but yesterday voted for Livni's Kadima party, saying that he hoped to be able to keep out a rightwing government.

"The main issue is the matter of rightwing versus leftwing," he said.

"It doesn't really matter how many votes Bibi [Netanyahu] or Tzipi gets. What is really important is who builds the coalition."