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