Democrats who watched the party’s presidential candidates debate on Saturday night thought that Sen. Bernie Sanders won the event, an Internet survey found, though they also said Hillary Clinton showed that she would do the best job of keeping the U.S. safe from terrorism.

Mr. Sanders was declared the winner by 44% of Democratic primary voters who watched the nationally televised debate, with 32% choosing Mrs. Clinton and 2% picking the third candidate onstage, Martin O’Malley, a former Maryland governor.

The...