CAIRO (AP) — Military helicopters buzzed overhead and hundreds of thousands of soldiers and police were deployed as Egyptians voted Tuesday on a new constitution in a referendum that will pave the way for a likely presidential run by the nation’s top general months after he ousted Islamist President Mohammed Morsi.

Four people were killed when gunfire broke out between police and gunmen on rooftops as clashes broke out between pro-Morsi protesters and security forces in the southern city of Sohag, according to security officials. Three others were wounded, including a senior police officer.

A Morsi supporter also was shot to death as he and about 100 others tried to storm a polling station in the province of Bani Suef south of Cairo, said the officials, speaking on condition of anonymity because they were not authorized to talk to the media. It was not clear who was behind the shooting.

In Cairo’s working class district of Nahya, pro-Morsi protesters shot at and pelted with rocks a polling station before closing all entrances with chains, scaring away voters and locking election officials inside, Mohammed Seragedeen, the judge in charge of the station, said.

Security forces later fired tear gas to disperse the protesters and allow voting to resume, he said.

The two-day balloting is a heavy blow to the Muslim Brotherhood’s campaign for the reinstatement of Morsi and paves the way for a likely presidential run by the nation’s top general, Abdel-Fattah el-Sissi.

A massive security operation was underway to protect polling stations and voters against possible attacks by militants loyal to Morsi, with 160,000 soldiers and more than 200,000 policemen deployed across the nation of some 90 million people.

Shortly before polls opened, an explosive device went off outside a Cairo courthouse in the densely populated neighborhood of Imbaba. The blast damaged the front of the building but caused no casualties.

Long lines of voters began to form nearly two hours before polling stations opened in Cairo, including in Imbaba, where the blast promptly whipped up anti-Brotherhood sentiment with chants and shouting against the Islamist group.

A small crowd of angry residents gathered outside the courthouse, some carrying posters of el-Sissi. “Everyone must go now and vote to show those dogs, the Brothers,” shouted one man.

Outside a nearby polling station, 67-year-old Alaa al-Nabi Mohammed echoed a similar sentiment — that Egyptians have consigned Morsi and the Brotherhood’s year-long rule to the past.

“I am here to send a message to the world and to those who hate Egypt that we want to live and get our country back on its feet,” he said.

The Tuesday and Wednesday balloting is the first electoral test for the popularly backed coup that ousted Morsi and his Brotherhood.

A comfortable “yes” vote and a respectable turnout would bestow legitimacy on the cascade of events that followed the coup while undermining the Islamists’ argument that Morsi remains the nation’s elected president.

Morsi’s Brotherhood, which is now branded as a terrorist group, has called for a boycott of the vote. Morsi himself is facing three separate trials on charges that carry the death penalty.

The unprecedented security surrounding the vote follows months of violence that authorities have blamed on Islamic militants. In the six months since Morsi’s ouster, there has been an assassination attempt on the interior minister as well as deadly attacks on key security officers, soldiers, policemen and provincial security and military intelligence headquarters.

Morsi’s supporters have said they would stage massive demonstrations and have labeled the draft charter a “constitution of blood.” In response, the government has warned it would deal harshly with anyone interfering with the referendum.

In the days running up to the vote, Egypt looked more like a country going to war rather than one preparing for a transition to democratic rule. The government and the overwhelmingly pro-military media have portrayed the balloting as the key to the nation’s security and stability over which there can be no dissent.

Hundreds of thousands of fliers, posters, banners and billboards exhort Egyptians to vote “yes.” Posters — and campaigns — urging a ‘no’ vote have led to arrests.

The referendum is the sixth nationwide vote since the authoritarian Hosni Mubarak was ousted in a popular uprising in 2011, with the five others possibly the freest ever seen in Egypt.

While unlikely to be stained by fraud, the vote is taking place at a time when many of the freedoms won in the uprising that toppled Mubarak have vanished in the months since Morsi was removed after just one year in office.

The new charter, drafted by a liberal-dominated committee appointed by the military-backed government, would ban political parties based on religion, give women equal rights and protect the status of minority Christians. But it also gives the military special status by allowing it to select its own candidate for the job of defense minister for the next eight years and empowering it to bring civilians before military tribunals.

The charter is in fact a heavily amended version of a constitution written by Morsi’s Islamist allies and ratified in December 2012 with some 64 percent of the vote but with a nationwide turnout of just over 30 percent.

Copyright 2014 The Associated Press.