Wes Moore, a bestselling author and former nonprofit leader, defeated former U.S. Labor Secretary Tom Perez to claim a prize that attracted 10 candidates: the right to run for Maryland governor in November as the Democratic nominee.