Children were among the casualties, but authorities were not prepared to say whether they were among the dead or the injured, or both, due to privacy considerations, said Mayor Bas Eenhoorn. Three of the wounded were hospitalized in critical condition.
After the rampage, the attacker shot himself in the head at the Ridderhof mall in Alphen aan den Rijn, a suburb 19 miles (30 kilometers) southwest of Amsterdam.
"It's too terrible for words, a shock for us all," said Eenhoorn.
The gunman was identified under Dutch privacy laws as 24-year-old Tristan van der V., and it was "all but certain" he acted alone, District Attorney Kitty Nooy said. She said he was a native Dutchman from Alphen who had previous run-ins with the law, including an illegal weapons possession charge that was dropped. He had a gun license, Nooy said.
She said notes had been found in both the shooter's house and his car, but she could not say whether they indicated a possible motive for the rampage and suicide - or whether they contained threats.
Two hours after the shooting, Eenhoorn ordered several other malls in the town evacuated, but he would not elaborate on the reason. Dutch television broadcasters showed a bomb squad searching a black Mercedes parked outside the Ridderhof mall that is believed to have belonged to the shooter.
A witness identified as Maart Verbeek told state broadcaster NOS the attacker appeared to be firing randomly.
"There was a panic in the mall, a lot of people running," said Verbeek, a pet shop owner. "I see the attacker coming, walking, and I go inside the store ... and I see him going by with a big machine gun."
Witness Martine Spruit, a 41-year-old receptionist, told The Associated Press she was shopping at a drug store when she heard bangs and people in the store hid behind shelves. When they realized a shooting was taking place, customers shouted for employees to lock the doors.
"Then we heard the shots getting further away, so he was walking back and forth," she said. "Then we thought we'd have a look and there were two people lying dead near the entrance... Then he came back shooting so we locked the door again."
Queen Beatrix and Prime Minister Mark Rutte issued statements saying they were shocked and sympathize with the victims and their families.
Hours after the shooting, residents continued to gather at the mall, some of whom appeared to be in a daze.
"You hear about this sort of thing happening at American schools and you think that's a long way away," said Rob Kuipers, 50, a project manager. "Now it's happened here in the Netherlands."
Nooy said there was "no evidence" to support rumors that the gunman was a former soldier or that his mother or father had been among the dead or wounded Saturday.
Witnesses said the attacker had long blond hair and wore a black jacket and camouflage pants.
A resident who lives near the mall who gave his name as Marijn said the shooting went on for minutes. When he went to see whether friends working at the mall were OK, he saw the assailant lying dead in a grocery store.
"There was glass everywhere," the resident said. "He was just shooting everywhere as if it were the Wild West."
Images published by the NOS showed the body of the gunman lying near a checkout counter.
With his voice choking at times, Mayor Eenhoorn described the incident as a "disaster of unparalleled proportions" for Alphen, known as a quiet residential suburb. The deadly attack also occurred during one of the region's first sunny days of spring, so many people were out and about.
"Under these circumstances, with many people shopping at the Ridderhof today, including parents with children, it's an almost incomprehensible situation," he said.
One unidentified witness on NOS TV said he saw the shooter change magazines of his machine gun and continue to fire.
Police commissioner Jan Stikvoort denied reports police were slow to respond, saying they arrived while the shooting was ongoing and reached the gunman just as the shooting stopped.
Although rare, shootings and violence are not unknown in the Netherlands.
In 1999, four students and a teacher were hurt in a school shooting and in 2004, a teacher was shot dead by a student.
There also have been two assassinations in the past decade, the 2002 killing of right wing politician Pim Fortuyn by an animal rights activist, and the 2004 murder of filmmaker Theo van Gogh by an Islamic extremist.
In 2009, a loner drove his car into a group of bystanders during a royal parade, killing eight and wounding 10.
Gun permits are difficult to obtain in the Netherlands, but illegal automatic weapons and ammunition are frequently seized during drug busts.
Two people were killed in Alphen in a drug-related shooting several weeks ago. Nooy said investigators do not believe the incidents are linked. She said investigators were trying to trace the gun or guns used in the attack.