Confronted by police at the headquarters of the opposition Union for Democracy and Justice on Friday, the crowd of between 300 to 500 people threw stones and attempted to block the road outside the office, prompting the response, they said.
"We had to use force to disperse them after several attempts to get them to leave peacefully," said Umar Hasan, a colonel in the Djibouti security force.
"The demonstrators did not have the right to organise like this," he said. "The campaign ended on Wednesday."
Incumbent President Ismail Umar Guelleh is running unopposed in Friday's election which the opposition has called a farce and urged voters to boycott.
The only unknown
With victory assured for the lone candidate, incumbent President Guelleh, the only unknown was whether an opposition call to boycott the polls would keep enough voters away to significantly tarnish the win.
Guelleh has said he hopes to get 75% of the vote and expects about 55% of registered voters to cast ballots.
Voters had a choice of a green ballot with Guelleh's name on it or nothing at all.
"If they want to express dissatisfaction, they can leave the envelope empty," said Abd Allah Muhammad Hersi, the chief election official at the Chateau d'eau school polling station in the capital.
"If they want to express dissatisfaction, they can leave the envelope empty"
Abd Allah Muhammad Hersi,
chief election official
Friday's elections are the third time Djibouti has gone to the polls in what is supposed to be a multi-party election but the first in which the president has not faced opposition.
In the last presidential election in 1999, the opposition won only 25% of the total votes, and it suffered another loss in September when its main leader and candidate, former prime minister Ahmad Dini Ahmad, died.
Since coming to power in 1999, Guelleh has turned Djibouti into a key western ally in the so-called war on terrorism.
Located at the southern end of the Red Sea on the Gulf of Aden, Djibouti is a key staging post between the Mediterranean and the Suez Canal as well as the Indian Ocean, and is home the largest overseas French military base and the only US military base in Africa.