One of former Prime Minister Benjamin Netanyahu’s closest advisers testified against him Monday in a long-running corruption case that could decide the political fate of Israel’s longest-serving leader.

The trial has become one of the starkest symbols of the reversal of fortunes for Mr. Netanyahu, who led the country for 15 years until he failed to form a government this spring. Prosecutors say Mr. Netanyahu accepted expensive gifts from wealthy businessmen in exchange for official favors and offered two media moguls regulatory...

One of former Prime Minister Benjamin Netanyahu’s closest advisers testified against him Monday in a long-running corruption case that could decide the political fate of Israel’s longest-serving leader.

The trial has become one of the starkest symbols of the reversal of fortunes for Mr. Netanyahu, who led the country for 15 years until he failed to form a government this spring. Prosecutors say Mr. Netanyahu accepted expensive gifts from wealthy businessmen in exchange for official favors and offered two media moguls regulatory and financial benefits in exchange for positive press coverage.

One of the prosecution’s key witnesses, Nir Hefetz, worked in Mr. Netanyahu’s inner circle for years, cultivating press coverage of the leader and his family while working as a go-between for the Netanyahus and powerful businesspeople. On Monday, Mr. Hefetz said Mr. Netanyahu was obsessed with his image in the press and on social media while in power.

“His control over everything relating to media matters and in his social media channels could not be higher,” Mr. Hefetz testified, with his former boss looking on in the courtroom.

Mr. Netanyahu—who became the first sitting Israeli prime minister to be indicted—has denied the charges and accuses Israeli prosecutors of conducting a political witch-hunt against him.

In his testimony Monday, Mr. Hefetz detailed the relationship between the prime minister and Israeli media mogul Shaul Elovitch. Mr. Netanyahu and his wife Sara are accused of using their connection with Mr. Elovitch, the then-majority shareholder of telecom firm Bezeq, to influence coverage on the Bezeq-owned Walla news site between 2012 to 2017. In return, prosecutors say, Mr. Netanyahu promoted regulation that would benefit Bezeq’s bottom line.

Nir Hefetz, at a Jerusalem court on Monday, worked in Mr. Netanyahu’s inner circle for years.

Photo: POOL/REUTERS

The former editor in chief and chief executive of the news site have taken the stand describing the pressure they faced from Mr. Netanyahu—mainly through his allies—to revise, remove or bury articles critical of the Netanyahu family, including stories about expensive candles and high water bills at the prime minister’s residence, and to promote positive coverage.

Mr. Hefetz said Mr. Netanyahu made him the point man with Mr. Elovitch and Walla, where he said he had a direct line with editor Ilan Yeshua.

“[I was] told I could speak with Walla editor Yeshua and he’d take care of me, meaning not me, but the prime minister,” he said.

The favors Mr. Netanyahu did for Mr. Elovitch were estimated to be worth $520 million, according to the indictment. Bezeq declined to comment. A lawyer for the Elovitch family said they deny the charges.

The trial will continue on Tuesday.

Mr. Hefetz, a former journalist, stood by the prime minister until his own arrest in 2018 in relation to Mr. Netanyahu’s corruption case. Later, he agreed in a plea deal to be a state witness against Mr. Netanyahu in return for immunity.

Testimony on Monday didn’t include any smoking guns, but the scene underscored the grim reality facing Mr. Netanyahu, who has had former allies turn on him.

One of his former party members,

Gideon Sa’ar, who defected from Mr. Netanyahu’s Likud Party last year and joined the current government in June, has proposed a bill that would prevent anyone facing criminal charges from forming a government. Mr. Netanyahu and his allies have called the bill a targeted attempt to prevent the former prime minister from returning to power before the trial is over. Mr. Sa’ar denies the legislation is aimed at his one-time boss.

Mr. Netanyahu, who is still popular within Likud, has seen a challenge for the group’s leadership from longtime ally Yuli Edelstein. However most political pundits see Mr. Netanyahu remaining the party’s leader for the foreseeable future.

“Netanyahu is very strong within the Likud and within the right-wing bloc,” said Gideon Rahat, chairman of the department of political science at the Hebrew University of Jerusalem. “I don’t think he can be replaced unless he’s willing to give up.”

Earlier this year, Mr. Netanyahu, who is still enjoys support among Israeli voters, was tasked with forming a government but failed to clinch the coalition partners needed.

Immediately after losing power, Mr. Netanyahu embraced his role as head of the opposition, challenging the government on any bill up for a vote. But with time, the opposition has lost steam and discipline in parliament, said Mr. Rahat.

The trial is expected to continue for years. If found guilty, Mr. Netanyahu could face up to 10 years in prison.

Israel is divided over the trial of Prime Minister Benjamin Netanyahu, who faces corruption charges including allegedly accepting gifts such as champagne, cigars and jewelry. WSJ’s Dov Lieber explains. Photo: Gali Tibbon/Associated Press The Wall Street Journal Interactive Edition

Write to Thomas Grove at thomas.grove@wsj.com