SEATTLE — Opponents of affirmative action have defeated a measure in Washington State that would have restored the use of that diversity practice in government agencies, public contracting and state colleges.

Washington was among the first states to ban affirmative action 20 years ago. But amid shifting attitudes about lingering inequities and racial divides, supporters believed that this year provided an opportunity to repeal the ban.

The measure ultimately fell just short of approval, a coalition in Washington that supported affirmative action acknowledged. Votes in Washington’s all-mail-ballot election on Nov. 5 were still being counted. But tallies as of Tuesday showed voters sustaining the ban with 50.4 percent of the vote. The ban initially passed in 1998 with 58 percent of the vote.

Now attention turns to other states and legal cases involving affirmative action, including the expectation that the United States Supreme Court, with a new conservative majority, may eventually be asked to weigh in once again.