Virginia Lieutenant Governor Ralph Northam, who is campaigning to be elected as the state's governor, and his wife Pam, cast their ballots at the East Ocean View Community Center in Norfolk, Virginia, U.S. November 7, 2017. REUTERS/Julia Rendleman

WASHINGTON (Reuters) - Democrat Ralph Northam was elected on Tuesday as Virginia’s next governor, U.S. media projected, handing his party a sorely needed victory and beating back a challenge from a Republican opponent who embraced President Donald Trump’s combative campaign style.

Northam, the state’s lieutenant governor, had seen his lead in the opinion polls diminish late in the race in the face of hard-edged ads by Republican Ed Gillespie touching on divisive issues such as immigration, gang crime and Confederate statues.