Republican Gregg Nelson, left, lost to Democrat Ibraheem Samirah in the special election to fill state Sen. Jennifer B. Boysko’s open seat in the House of Delegates. (LEFT: Gregg Nelson for Delegate; RIGHT: Antonio Peronace)

Virginia Democrat Ibraheem Samirah on Tuesday became the second Muslim elected to the General Assembly, in a special election marked by allegations of anti-Semitism over anti-Israel social media posts.

In what political analysts saw as a measure of whether recent scandals involving Virginia’s top elected officials might hurt Democrats, Samirah easily beat Republican Gregg G. Nelson and independent Connie H. Hutchinson with 59 percent of the vote, according to unofficial results.

That means the House of Delegates seat left vacant by the election of Jennifer B. Boysko to the state Senate will remain in Democratic hands, months before Democrats attempt to seize the majority in both chambers of the General Assembly.

Samirah, a Palestinian American dentist from Herndon, said he relied more on volunteers than elected Democrats in the days leading up to the election, as the party dealt with fallout from his social media posts along with allegations of racism against Gov. Ralph Northam (D) and Attorney General Mark R. Herring (D) and sexual assault accusations against Lt. Gov. Justin Fairfax (D).

“It landed us in a position where we solely relied on grass roots,” said Samirah, 27, who, among other issues, campaigned on expanding affordable health care and pushing for universal prekindergarten.

Nelson, 63, a retired Air Force sergeant, pledged to reduce taxes and invest more in road improvements. Hutchinson, 64, a former Herndon Town Council member, cast herself as a bridge builder.

The race grew heated earlier this month after the same right-leaning website that broke the Northam and Fairfax allegations wrote about Samirah’s Facebook posts from 2014.

In one, Samirah shared an angry letter by musician Brian Eno about Palestinian civilian deaths caused by Israeli missile strikes in Gaza. The letter said funding Israel is like supporting the Ku Klux Klan. “I’d say worse, but I’ll go along with Eno on this one,” Samirah wrote above it.

In a different post, after the death of Ariel Sharon in 2014, Samirah wrote that the former Israeli prime minister should “burn a million times for every innocent soul you killed.” He wrote that he wished the same for “our beloved Arab ‘leaders’ (butchers I should say).”

Nelson called the posts anti-Semitic, linking them to revelations that Northam and Herring appeared decades ago in blackface.

“Racism has no place in our Commonwealth. Especially from individuals in office or seeking office,” Nelson wrote on his own Facebook page.

Samirah apologized for his posts, though he characterized the attacks as “a smear campaign.”

Virginia Democrats have seen a string of strong victories in recent elections, buoyed by a growing suburban population and opposition to President Trump. But the scandal-weakened governor, lieutenant governor and attorney general are not expected to be campaign-trail assets for the all-important contests in November.

On Monday, Sens. Mark R. Warner (D) and Tim Kaine (D) met with Democratic lawmakers in Richmond to reassure them that they would step in to help. “ ‘We want to be there for you. We’re going to do everything we can to help you,’ ” one Democratic lawmaker, who spoke on the condition of anonymity to discuss a private meeting, quoted them as saying.

Samirah got little of that support in recent days. For most of the race, he was the favorite, the $89,000 in his campaign coffers dwarfing the $20,300 raised by Nelson and the $2,800 collected by Hutchinson. But several early backers distanced themselves after reports about the social media posts.

Boysko had her endorsement of Samirah removed from his Facebook campaign page and then renewed her public support Tuesday.

“We need to keep this seat for the Democratic Party,” she said in a short video. “We really need Ibraheem in the House of Delegates.”

Samirah, whose district covers mostly northwestern Fairfax County, joins Del. Sam Rasoul (D-Roanoke) as the second Muslim elected to state office in Virginia. He said he felt abandoned by his party leaders over the controversy, which he noted was first reported by a Republican-leaning website.

“I can’t lie about that,” Samirah said. “They definitely succumbed to the extreme-right propaganda machine. They succumbed to fear when we should be standing up for our values and not allowing them to divide us and conquer us.”

Laura Vozzella contributed to this report.