"The national responsibility (bestowed) by the public brings me to approach this job with great awe," Livni said shortly after the results were announced.
Livni, a political moderate, won 43.1 percent of the vote in the Kadima Party primary elections, compared with 42 percent for Shaul Mofaz, a hawkish former military chief and defense minister, in a contest with far-reaching implications for peacemaking with the Palestinians and Syria.
The official results were much closer than the double-digit victory predicted by exit polls Wednesday night.
Olmert, who is stepping down to battle multiple corruption allegations, will remain as a caretaker leader until parliament approves a new Cabinet. He will resign after the next Cabinet meeting on Sunday, but spokesman Mark Regev would not say when exactly.
Livni said she would launch informal coalition talks on Friday, even though President Shimon Peres cannot officially ask her to try to put together a government until Olmert resigns. After she is assigned the task, she will have 42 days to form a new ruling coalition.
If she succeeds, she will become Israel's first female prime minister since Golda Meir stepped down in 1974. If she fails, the country will hold elections in early 2009, a year and a half ahead of schedule.
Livni is Israel's lead negotiator in peace talks with the Palestinians and a rare female power figure in a nation dominated by macho military men and a religious establishment with strict views on the role of women.
A lawyer and former agent in the Mossad spy agency, she is eager to continue the low-decibel diplomatic efforts. She says she hopes diplomatic efforts to halt Iran's nuclear program will prevail, though she says all options are on the table.
Jerusalem resident Shula Lon said she hoped Livni's non-confrontational approach could help the peace efforts.
"I really wish her the best, that she will bring peace," she said. "After so many generations (when) nobody succeeded, maybe a woman could do it now."
But Robert Bonam, another Jerusalem resident, said he feared that Livni's lack of military command experience could leave the country vulnerable in a fight with its enemies.
Livni's victory puts her in a strong position to become Israel's prime minister, though that is not guaranteed and the process could take weeks. Livni says she wants to keep the governing alliance intact, but that is likely to mean tough negotiations over Cabinet posts and budgets.
With opposition leader Benjamin Netanyahu's hardline Likud Party polling well, neither Kadima nor its allies appear eager for a new election. But with the Shas party, a key coalition partner, making tough demands, Livni will have to perform some deft political maneuvering to put together a government.
The ultra-Orthodox Shas opposes shared control of Jerusalem - the holy city claimed by Israel and the Palestinians. As lead peace negotiator, Livni is committed to discussing all the issues between Israel and the Palestinians, and the future of Jerusalem is at the heart of the conflict.
"If it becomes clear that Jerusalem is on the negotiating table ... then we won't be part of the coalition," Shas spokesman Roi Lachmanovitch said.
Nationally, polls show Livni roughly tied with Netanyahu should balloting be held today. A new nationwide vote would likely turn into a referendum on the current effort to forge a historic peace deal with the Palestinians.
Palestinian Information Minister Riad Malki was hopeful that peace talks could succeed under Israel's new leadership.
"We welcome the results of the election, and we are going to deal with any new prime minister in Israel," he told The Associated Press.
But West Bank resident Mustafa Shaaban was skeptical that things will improve. Speaking as he waited to pass through an Israeli military checkpoint, said frequent changes of leadership through Israel's 60 years of statehood have brought no real change in attitudes toward Palestinians.
"Since 1948 Israel is the same," he said. "Whatever changes in leadership, it will have the same internal policy."
Wednesday's primary was Kadima's first since the party was founded by then-Prime Minister Ariel Sharon in 2005. Sharon suffered a debilitating stroke in early 2006, and Olmert subsequently led the party to victory in elections.
Sharon set up Kadima as a personal bastion after his hard-line colleagues in Likud blasted his unilateral pullout from the Gaza Strip in 2005. It was widely predicted Kadima would disintegrate after his exit, but the moderate Livni's victory appeared to give it a chance of survival.
Olmert is under police investigation over his financial dealings. But he has been pursuing peace talks with the Palestinians and has pledged to continue as long as he is in office. However, both he and his Palestinian counterparts now say they are unlikely to reach the U.S.-set target date of year's end for a final peace deal.
Three TV exit polls released just before the voting ended Wednesday night had showed a clear victory for Livni over Mofaz, about 47 percent to 37 percent, leading to premature celebrations. But official results saw that margin shrink dramatically to a 431-vote edge. This was not the first time exit polls have badly missed their mark here.
Livni needed 40 percent of the vote to avoid a runoff next week. Two other candidates lagged far behind in the tally.