JERUSALEM, June 13 — Ehud Barak, a former prime minister of Israel, returned to the political scene on Wednesday as the new leader of the Labor Party, and the deputy prime minister and elder statesman, Shimon Peres of the ruling Kadima Party, was elected by Parliament to the largely ceremonial post of president.

Both developments are likely to reinvigorate the leadership of the beleaguered prime minister, Ehud Olmert, and increase his endurance, Israeli officials and analysts said.

In a startling comeback after a six-year break from politics, Mr. Barak defeated Ami Ayalon, a legislator of one year and a former director of the internal security agency, in a runoff of party members, by 51.2 percent to 47.8 percent.

Mr. Barak is expected to assume the post of defense minister, replacing the ousted Labor leader Amir Peretz. In his victory speech early on Wednesday, Mr. Barak called on Mr. Ayalon and other Labor colleagues to work with him in a party notorious for infighting.

“The internal competition has come to its end,” Mr. Barak said. “Now it is up to each of us to work in our own field. I am talking about investing all our knowledge in strengthening the defense establishment and the I.D.F. and restoring Israel’s power of deterrence,” he said, referring to the Israeli Defense Forces.

Mr. Olmert’s aides contend that the partnership with Mr. Barak, a former army chief of staff often described as Israel’s most decorated soldier, will restore public confidence in the government after an official investigating committee accused it of “severe failures” in the war in Lebanon last summer.

But Mr. Barak brings his own baggage on the issue, having presided over Israel’s unilateral withdrawal from southern Lebanon in 2000, a move some say contributed to the conditions that led to the war last summer. Mr. Olmert and Mr. Peretz were harshly criticized in the war report, the first part of which was published in late April.

The post of finance minister is also open. The previous minister, Abraham Hirchson of Kadima, took a leave of absence pending the outcome of a police investigation into allegations of corruption and embezzlement. Mr. Peres’s election to the presidency opens an additional government portfolio, giving Mr. Olmert — who is also being investigated in a corruption case and whose approval ratings sank to 3 percent in recent months — room to maneuver.

“There will be negotiations over the new appointments, and they will strengthen and stabilize the coalition,” said an official close to Mr. Olmert, speaking on condition of anonymity. “It’s a good day for the prime minister,” the official said.

Mr. Barak had called on Mr. Olmert to heed the war report’s conclusions and resign. Nevertheless, Mr. Barak has said that he will keep Labor in the governing coalition at least until the publication of the final part of the war report, due in August.

“Barak has made it clear that his goal is to become defense minister, and stay defense minister,” said Gadi Wolfsfeld, a professor of political science and communications at Hebrew University in Jerusalem. “If Barak finds a way to stay in the government, Olmert won’t fall.”

Mr. Barak does not favor early elections, probably because Benjamin Netanyahu, the leader of the right-wing Likud Party, has consistently emerged as the front-runner in opinion polls. But Mr. Barak beat Mr. Netanyahu for the premiership in 1999, and in his primary campaign he presented himself as the Labor candidate with the best chance of doing so again.

Mr. Peres, Mr. Olmert’s candidate for president, ran against Likud’s Reuven Rivlin and Labor’s Colette Avital, the first woman to seek the job. Though the role of the president is largely symbolic, many saw the vote in Parliament as a test of prestige and confidence in Mr. Olmert.

In the first round, Mr. Peres received 58 votes in the 120-member Parliament, just short of the 61 needed to win outright. Ms. Avital, who received 21 votes, withdrew before the second round, followed by Mr. Rivlin, who won 37. An emotional Mr. Rivlin called on all members of Parliament to vote for Mr. Peres. Ms. Avital said she was proud to have “broken the glass ceiling” by running, and gave her support to Mr. Peres.

He won 86 votes in a for-or-against second ballot, held for reasons of protocol. He thanked Mr. Rivlin and Ms. Avital for their “notable” gesture.

The victory of Mr. Peres, who is nearly 84, was greeted with relief in many quarters, because he has a reputation as a loser. He has been in Parliament since 1959, and has served in most senior government posts, twice as prime minister. But he had never before won a major post in his own right. His most stinging defeat occurred in 2000, when he was beaten for the presidency by Moshe Katzav of Likud. Mr. Barak, 65, entered politics in 1995 and was first elected to lead Labor in 1996.

Copyright 2007 The New York Times Company