The 28-year-old was held on Tuesday after allegedly trying to strangle one woman with her bare hands, and stabbing another woman in the neck.
The second victim in the attack, in Lugano in the south of Switzerland, was said to be seriously wounded.
“The perpetrator is known to @FedpolCH,” the federal police said on Twitter. “She appeared in a police investigation in 2017 in connection with jihadism.”
The regional police had already mentioned a possible terror motive behind the attack.
“The situation is extremely serious,” said Norman Gobbi, head of the Ticino regional government.
The woman was overpowered by customers in the shop before officers arrived.
The Swiss federal police said criminal proceedings were under way.
“This attack does not surprise me”, federal police chief Nicoletta della Valle said Tuesday, underlining that such attacks occurred all over the world.
Switzerland has not suffered a major jihadist attack, but police and officials highlighted several recent incidents being investigated for possible terrorist motives.
And two Swiss nationals aged 18 and 24 were arrested near Zurich due to their alleged links to the perpetrator of a deadly attack in neighbouring Austria's capital Vienna earlier this month.
After Tuesday's incident, Austrian Chancellor Sebastian Kurz tweeted that he condemned the “Islamist terrorist attack” in Lugano.
“We stand with Switzerland in these difficult hours,” he wrote.
“We'll give a joint response to Islamist terrorism in Europe and defend our values.”
An Islamic State sympathiser who had tried to join the jihadist group in Syria was behind the attack in Vienna, in which four people were killed and several others injured.