Two terrorists were captured, Israeli police spokesman Micky Rosenfeld said, with one shot and the second arrested at the upscale Sarona Market.
There was no immediate claim of responsibility for the attack, which Prime Minister Benjamin Netanyahu called "a savage crime, murder in the heart of Tel Aviv."
"We will take the necessary steps to attack the attackers and defend those who need to be defended," he said.
Surveillance footage from a cafe near the shooting scene showed chaos as panicked customers knocked over chairs and tables as they rushed to escape. People crawled across the floor and others carried children in their arms.
Violence shatters serene setting
Amir Ohana, a member of the Israeli Parliament who was at Sarona Market, told CNN that people were enjoying a serene night when violence erupted.
"People were having coffee," he said. "I saw a birthday cake on one of the tables. And then you see the chairs upside down and glass shattered and blood all over."
The four fatalities were Israeli, Rosenfeld said. At least five other people were wounded in the carnage, said Dr. Gil Fire, deputy director of Ichilov Hospital.
An injured suspect also was treated.
Information about a motive wasn't immediately available. No intelligence suggested an attack was imminent, Rosenfeld said.
The attackers were dressed as Hasidic Jews, said a law enforcement source briefed by Israeli officials. Police officers shot one of the suspects. The other surrendered, Rosenfeld said.
Concerns about security?
Sarona Market is a mixed-use development with a food hall, upscale retail, playgrounds, green space and residences on a central highway. The market, which opened last year, is across the street from Israel's Defense Ministry and main army headquarters.
A press release from the opening of the complex described it as an 8,700-square-meter complex with 91 stalls, shops and restaurants selling food from around the globe.
The Jerusalem Post reported in April that Tel Aviv police wanted to close the market because of "security flaws and safety shortcomings that present a risk to the public's safety."
But a spokesman for Gindi Holding, which built the market, told The Post the complex would not be closed and that violations only involved tables and chairs blocking entrances and exits and the way security guards were inspecting visitors at the door.
Violence in Tel Aviv
Tel Aviv is not as violent as Jerusalem, but has not escaped bloodshed.
Two people were killed January 1
when a gunman sprayed bullets from an automatic weapon near a pub in Tel Aviv. Seven people were wounded. In March, an American was killed
and 10 other people were wounded in a stabbing along an oceanfront boardwalk. Anti-police riots broke out
in May 2015.
U.S. State Department deputy spokesman Mark Toner issued a statement condemning "today's horrific terrorist attack in Tel Aviv in the strongest possible terms."
"These cowardly attacks against innocent civilians can never be justified," he said. "We are in touch with Israeli authorities to express our support and concern."
Israeli Ambassador to the United Nations Danny Danon called on the Security Council to condemn the attack.
"Today's heinous attack sadly proves that when the international community refuses to condemn terror against Israelis, the next attack is only a matter of time," he said in a statement. "Terror in Tel Aviv must be treated the same as terror in Paris or Istanbul."
Rosenfeld said knife attacks have been more common lately, with the last shooting in Tel Aviv occurring months ago.