Dusan Vranic, Associated Press
Syrian soldiers walks past a bus with President Bashar Assad's portrait in Damascus, Syria, Tuesday June 3, 2014. Polls opened in government-held areas in Syria amid very tight security Tuesday for the country's presidential election, a vote that President Bashar Assad is widely expected to win.

DAMASCUS, Syria — Waving photos of President Bashar Assad and dancing with flags, tens of thousands of Syrians pledged renewed allegiance to President Bashar Assad as they voted Tuesday in a presidential election that excluded a vast swath of the pre-war population and was decried by the opposition as a charade.

Some stamped their ballots with blood after pricking their fingers with pins supplied by the government in a symbolic act of allegiance and patriotism. Others chose to vote in full sight of other voters and television cameras — rather than go behind a partition curtain for privacy.

Men and women wore lapel pins with Assad's picture and said re-electing him would give the Syrian leader more legitimacy to find a solution to the devastating three-year conflict that activists say has killed more than 160,000 people, about a third of whom were civilians.

Security was tight, with multiple rings of checkpoints set up around the Syrian capital and its entrances. Troops searched cars and asked people for their IDs.

Even as crowds of Assad's supporters flocked to the polls in Damascus, the sounds of war were inescapable.

At least three fighter jets roared low over Damascus during the voting, which residents said was unusual.

The dull sounds of explosions also reverberated in the distance as pro-government forces and rebels battled in nearby rural towns and ashy plumes of gray smoke marked the skyline. Several mortar hits were reported in the capital, including one that crashed near the Opera House on a major plaza, though the voting was largely peaceful.

The balloting is only taking place in government-controlled areas, excluding much of northern and eastern Syria. Tens of thousands of Syrians abroad voted last week, although many of the more than 2.7 million Syrian refugees across the region either abstained or were excluded by voting laws.

Assad's win — all but a foregone conclusion — would give him a third seven-year term in office, tighten his hold on power and likely further strengthen his determination to crush the insurgency against his rule.

The opposition's Western and regional allies, including the U.S., Britain, France, Saudi Arabia and Turkey, have called the vote a sham. The so-called internal Syrian opposition groups seen as more lenient are also boycotting the vote, while many activists around the country are referring to it as "blood elections" for the horrific toll the country has suffered.

The vote is also Syria's first multi-candidate presidential election in more than 40 years and is being touted by the government as a referendum measuring Syrians' support for Assad. He faces two government-approved challengers in the race, Maher Hajjar and Hassan al-Nouri, both of whom were little known in Syria before declaring their candidacy for the country's top post in April.

In government strongholds of Damascus and Latakia, the voting took on a carnival-like atmosphere, with voters singing and dancing, all the while declaring undying loyalty to Assad.

In Homs, Syria's third-largest city, the atmosphere was more restrained, with people standing in long lines to vote. Even the destroyed Old City, recently evacuated by hundreds of rebel fighters after a cease-fire agreement with Assad's government forces, had a few polling stations, including one placed in the courtyard of the heavily damaged St. Mary's Church of the Holy Belt.

Mohammed Hussam, an opposition activist in the eastern half of the contested northern city of Aleppo, said no voting was taking place in "liberated" areas, as rebels call areas they control. Speaking via Skype, he said there was much anger about the "theater" taking place in government-held parts of western Aleppo.

The government has presented the election as the solution to the conflict, but there is no indication it will halt the violence or mend a bitterly divided nation. The stage-managed balloting also will likely put to rest any illusions that the man who has led Syria since 2000 has any intention of relinquishing power or compromising to reach a political solution.

Assad cast his ballot in the morning at a school in his posh Damascus neighborhood of al-Malki. The TV showed him in a dark blue suit and tie, flanked by his wife, Asma, both smiling as they inserted their ballots in a transparent box.

In his first public appearance since undergoing heart surgery in March, Foreign Minister Walid al-Moallem voted with a Syrian flag wrapped like a shawl around his neck.

"The path toward a political solution to the crisis begins today," he declared.

At a polling station in the upscale Dama Rose hotel in central Damascus, a cup filled with pins was on offer for those who chose to vote in blood. Some pricked their fingers repeatedly to ensure they drew enough blood to mark the circle under Assad's name on the ballot. Most, though, voted in ink.

"With the leadership of Bashar, my country will return to safety," said student Uday Jurusni, who voted in blood, after pricking his finger. "He is my leader and I love him."

Outside the hotel, about two dozen men banged drums, waved flags and danced as they chanted, "God, Syria and Bashar!" Streets around polling centers were awash with Assad posters.

In one Damascus polling station, government official Basam Ramadani stood with a small pile of syringes instead of pins for those wishing to vote in blood.

After using one of the syringes, voter Firyal Sheikh El-Zour, 50, proudly displayed her bloodied finger to the media. Another voter suspiciously glanced at the syringes, then muttered: "Give me a clean needle."

The Interior Ministry said there were 15.8 million eligible voters, both inside and outside Syria, and that 9,600 voting centers have been set up around the country. Polls were expected to close at 7 p.m, but the ministry has said voting could be extended for five hours if there was a big turnout.

A London-based Syrian opposition figure, Muhieddine Lathkani, called the vote a "black comedy."

"This election has no value and no one will recognize it, no matter what North Korea and Iran think about it," he said, referring to some of the key states allied with Assad.

Associated Press writers Bassem Mroue and Zeina Karam contributed to this report from Beirut.