Democratic Gov. Phil Murphy of New Jersey narrowly won reelection in his reliably blue state while a Republican political newcomer delivered a stunning upset in the Virginia governor's race, sending a warning Wednesday to Democrats that their grip on power in Washington may be in peril.