Two outgoing members of Congress who also served in the state legislature were vying Tuesday for the post of North Carolina attorney general, a closely watched race for a job that has gained increasing prominence in states across the country.