Opinion surveys were mostly split on who will win the ballot to replace Amir Peretz, the current Labour chief defence minister, who became the latest casualty of last year's Lebanon war.
Peretz came in a distant third during a first round of voting on May 28.
But a poll of 500 Labour members released by Israel's Channel 10, late on Monday, predicted Barak to lead with a 46 per cent win against 39 per cent for Ayalon - with the rest of the party's 100,000 members undecided.
"The race is very close, and the election will be decided by several hundred votes to this or that side," Nissim Zvili, the former Labour general secretary, said.
Both Ayalon and Barak have vowed to pull Labour, Olmert's main coalition partner, out of the government unless the premier steps down following criticism of his handling of the war.
But behind the campaign slogans, both men appear more cautious, aware that they may not be able to form a new majority and loath to face early elections that most surveys show the right-wing opposition Likud would win, analysts say.
"Olmert may just as well watch one of the sports channels tomorrow evening, instead of the results from the Labour primary ... Labour is not going anywhere in the next few months," Akiva Eldar, a political analyst of the liberal Haaretz daily, wrote.
A senior official with Olmert's Kadima party said: "I can't see any indication that Labour will leave the government. On the contrary, the coalition will only stabilise after the primary elections."
The immediate outcome of Labour's vote will be a reshuffle within the cabinet that "will strengthen both Labour and Olmert," the official said, speaking on condition of anonymity.
The sentiment was echoed by allies of both men.
"In principle, Ami does not want to stay in Olmert's government. But in principle, he does not wish to break the coalition government. If he has no choice, Ami will continue Labour's partnership with Olmert," Zvili, an Ayalon supporter, told AFP.
Eitan Cabel, the Labour general secretary, who backs Barak, said: "The watershed moment will be the release of the full war report [by August], and when that moment arrives, we will make our assessments.
"But I strongly hope we will not stay in Olmert's government," Cabel said.
He quit Olmert's government after the release of an interim government inquiry that criticised his handling of the 34-day war with Hezbollah last summer.
Olmert intends to invite Labour's newly-elected chairman, as early as this week, to brief him on the security situation in the Gaza Strip and Lebanon, officials in the prime minister's office said.
Both Ayalon and Barak have emphasised their strong security backgrounds and have declared their intention to replace Peretz as defence minister.
Labour also intends to demand the finance portfolio, today held by Olmert's Kadima.
Further changes could take place if Shimon Peres, the deputy prime minister of Kadima, is elected Israel's new president on Wednesday.
Barak, 65, a former army chief of staff and Israel's most decorated soldier, and Ayalon, 61, a former head of the Shin Beth internal security service, have both vowed to rebuild the Jewish state's deterrence after the inconclusive war in Lebanon.