The Israeli military said its air defense system, known as Iron Dome, intercepted the rocket. There were no reports of casualties.
The Israeli newspaper Haaretz posted a video on its website showing Netanyahu being taken to a shelter as he was campaigning hours before the primaries of his Likud party. The video showed Netanyahu and his wife slowly walking off the stage with security guards after sirens went off.
Early Thursday, Israeli fighter jets and helicopters carried out multiple strikes at three military bases for Hamas, the Islamic movement that rules Gaza, according to witnesses in Gaza. No casualties were reported as the sites have been empty.
There was no immediate comment from Israel's military.
Netanyahu says he knows how to protect Israel, but opponents accuse him of being soft on handling threats from Gaza.
Gideon Saar, Netanyahu's challenger in Thursday elections, called in a Twitter statement for a "broad national consensus for dismantling the military infrastructure" of Palestinian militant groups Hamas and Islamic Jihad.
A similar incident happened in September when Netanyahu was in the nearby city of Ashdod. He was campaigning then for the second general Israeli election of the year. That was believed to have triggered Israel's targeted killing of a senior commander in the Islamic Jihad in November. Israel and Gaza militants had their worst round of fighting in months as a result.
No Palestinian group claimed responsibility for Wednesday's attack. Such sporadic launches of rockets and ensuing Israeli airstrikes have happened frequently despite an Egyptian-brokered cease-fire that ended two days of fighting in November.
Hamas seeks "understandings" with Israel to alleviate Gaza's economic and humanitarian crises. The militant group stayed on the sidelines during the November flare-up.