TEL AVIV—The last email Israeli tech executive Itamar Ben Hemo sent before a bullet ripped through his ribs, diaphragm and intestine was a note to a colleague. Ben Hemo wanted to know how close the startup he founded was to signing on a new client.

For weeks, Ben Hemo—an Israeli army reservist who returned to active duty after Hamas’s deadly Oct. 7 attack on southern Israel—had been using breaks in combat to fire up his laptop, messaging investors and working on making his next sales.

Then, on Jan. 8, Ben Hemo’s paratrooper unit was summoned into action to rescue a wounded soldier pinned down in Gaza. The 49-year-old major and his compatriots were ambushed by Hamas fighters firing rocket-propelled grenades.

Then there was a spray of bullets. Ben Hemo felt hot pain rush through his body. “I got hit!”

Ben Hemo was fighting for his life. And the company he launched in 2019 was leaderless.

Tens of thousands of Israelis who work in the country’s vaunted technology sector have been fighting in what is already the longest war since Israel’s foundation in 1948. That is sapping the strength of one of the most important drivers of the national economy.

Over the past two decades, economic output has tripled as the tech sector has boomed. The money has turned Tel Aviv into a wealthy city, and meant Israelis, once familiar with economic austerity, became used to expensive cars, celebrity-chef restaurants and holidays abroad.

But as Israel’s best and brightest are killed and injured, or just absent during long stretches at the front, their tech businesses back home are struggling.

Investors are spooked by the fighting in Gaza and the prospects for a widening war with Hezbollah in Lebanon. Half of startups recently surveyed by Israel’s government innovation authority said they would run out of cash in six months, and many fear they won’t secure more funding.

More than 240 Israeli soldiers have been killed and thousands more left injured in Israel’s operation in Gaza, sparked by a Hamas attack on Oct. 7 that Israel says killed 1,200 people. More than 30,000 Palestinians have died in the fighting, according to Gazan health authorities, whose figures don’t distinguish between civilians and combatants.

Ben Hemo personifies the Israeli tech sector’s rise. He graduated with a computer science degree in 2002 and soon after started his first technology company, later selling a majority stake to investors.

In 2019, he founded Rivery, which helps companies to integrate and better understand data collected from various sources, such as apps that track sales performance, employee vacation days or customer details.

With salt-and-pepper hair and infectious enthusiasm, Ben Hemo persuaded Israeli venture-capital firms State of Mind Ventures and Entrée Capital to put up money. In 2022, he won investment from Tiger Global Ventures, one of the biggest U.S. venture-capital firms.

Before the war, Rivery had raised $48 million in investment and had 80 employees in offices in Tel Aviv, New York and London and 400 customers, including news site BuzzFeed and German pharmaceutical company Bayer .

On Oct. 7, Ben Hemo was set to go on a weekslong trip to London and New York. Instead, he volunteered to fight as a reservist. He believed his experience in conflicts in Lebanon in 2006, and Gaza in 2009 and 2014, would be valuable.

For the first few days, he helped evacuate people from communities attacked by Hamas around the border of the Gaza Strip, and then spent three weeks in training as Israel prepared an invasion of the enclave to destroy Hamas militarily.

In a video meeting with his senior management, Ben Hemo explained it wasn’t clear how long he would be in the army or whether he would be available but he told his leaders to step up and trust their own decisions.

For weeks, Ben Hemo spent roughly one day inside Gaza and one day out. His unit was involved in searching for and destroying Hamas’s tunnel network. He talked with fellow soldiers about how they hoped to find hostages taken by Hamas and other Palestinian groups on Oct. 7.

On rest days at his unit’s campsite on the Gaza border, Ben Hemo charged his phone and laptop using the army’s generators and did videoconference calls, including a quarterly board meeting, sitting in his Volvo. undefined undefined At Rivery’s offices, the company’s management team continued to make sales, signing its biggest contract ever with a large consumer-goods company, said Scott Hanrahan, Rivery’s head of sales. Still, the company put on hold a planned fundraising this year. undefined undefined Even before the war, Israeli startups were having a difficult year, with a divisive government campaign to overhaul the country’s judicial system aggravating the impact of a global slump in venture investing. The conflict has deepened the funding woes.

In November, for instance, Israeli venture capitalists set up an emergency fund, called Iron Nation, to provide cash for startups struggling to raise money. The initiative, one of a few like it, set a goal of raising $20 million to help roughly 30 startups and received applications from more than 700 companies needing cash.

Israel’s big technology firms, with a large percentage of their staff overseas and products sold in the U.S. and Europe, have weathered the war’s challenges. But the country faces a lost generation of the next big companies if technology startups fail.

On Jan. 8, the bullet that hit Ben Hemo missed his body armor and ripped through his internal organs before passing out his back. His commanding officer was also hit. Soldiers radioed frantically for help.

As blood soaked through Ben Hemo’s uniform, he thought to ask a fellow soldier, Tzion Gidoni, to give a message to his wife and four children, telling them sorry and that he loved them and didn’t mean for his life to end up this way.

Soon, reinforcements arrived in a convoy of armored vehicles and soldiers formed a protective cordon as medics fought to stabilize Ben Hemo, whose injuries were so severe that it was decided he needed immediate medevac to a hospital for trauma surgery.

He arrived at an Israeli hospital on the edge of Gaza about 30 minutes later and was whisked straight into the operating room. His wife and four children rushed from their home in central Israel to the hospital.

At Rivery, head of human resources Rotem Amitai crafted a message to inform employees that the CEO had been injured but that business would attempt to continue as usual.

Before the company had a chance to inform clients, many found out through social media, so Rivery tried to reassure them it was “operating and open,” said Amitai.

Roughly 48 hours later, doctors at the hospital tried to wake Ben Hemo from a medically induced coma. The bullet had damaged his lungs, intestine, ribs and diaphragm. Doctors removed his spleen during surgery. And they were unsure of his prognosis.

Slowly, Ben Hemo opened his eyes, and saw his wife, Porat. She asked how he was feeling. He told her he was sorry, and she wept at his bedside.

Only two people were allowed in the hospital room at a time, so people came in pairs—Ben Hemo’s children, his friends, and his investors. Avi Eyal, one of the early investors in Rivery, entered and kissed Ben Hemo on the forehead.

When Ben Hemo was reunited with Gidoni, the chief executive asked his friend if he’d relayed the message to his wife and kids. It turns out Ben Hemo hadn’t even asked him to do so.

As his memories came back, Ben Hemo remembered that after thinking about asking his friend to send a message, he decided against it, believing it defeatist.

“I remember that I felt like a startup: You need to believe that you are not going to die now,” he said.

On Jan. 24, Rivery organized an online board meeting to go over the company’s performance in the fourth quarter. Ben Hemo led the three-hour meeting from his hospital bed, poring over financial performance and the budget for this year.

At the start of the meeting, he didn’t address his health. Near the end, one of the board members, Nir Adler of State of Mind Ventures, took a moment to say everyone was impressed that Ben Hemo had made the effort, thanking him for his personal resilience and that of the Rivery management.

“This is a bit too cheesy, let’s move on,” Ben Hemo said he replied.

The chief executive is still in and out of the hospital, spending part of the week there and part at the office or home. He still holds multi-hour meetings with executives at his bedside, before heading to physical therapy.

He said doctors expect him to make a full recovery within months.

Ben Hemo said the Israeli tech industry should now expect to face difficulties raising money from overseas investors and a wave of anti-Israel sentiment. But, he said, he believed tech companies would keep driving the country’s economy.

“It’s not an easy situation to manage,” he said. “Personally, I want peace. I don’t want to fight.”

Write to Rory Jones at Rory.Jones@wsj.com