CONTRACTORS THAT DO business with the federal government, according to the Labor Department, employ roughly 26 million people, 22 percent of the workforce. In exchange for federal work, contractors have to agree not to discriminate on the basis of race, color, national origin, religion or sex. But the legal protections do not extend to sexual orientation or gender identity.

Federal legislation to prohibit employment discrimination against gay people has been introduced in virtually every congressional session for the past two decades with no success. Chances are minuscule that its fate in this session will be any different. Gay rights advocates fear that gay and transgender employees of federal contractors could be left vulnerable for years to come if a Republican takes the White House. There is an alternative, they argue: President Obama can act now through an executive order to extend such protections.

President Clinton issued an executive order to protect federal government employees from discrimination on the basis of race, national origin, religion and sexual orientation.

Executive orders have also been used as far back as the administration of Franklin D. Roosevelt to advance fairness in the employment polices of federal contractors. In the 1960s, President Lyndon B. Johnson signed into law the executive order that obligates contractors to adopt nondiscriminatory employment practices.

Mr. Obama could amend that order or issue a new one to order federal contractors not to discriminate in their workplaces on the basis of sexual orientation or gender identity. He would have the vast majority of Americans on his side: A poll conducted last year of likely 2012 voters showed that 73 percent of respondents favored workplace protections for gay and transgender people.

Business, too, would likely be an ally. Most of the largest federal contractors have adopted broad nondiscrimination policies that include sexual orientation. Such policies, companies have said, help to attract and retain the most talented workers in their field. An executive order affirming nondiscrimination would, according to a new study from the Williams Institute, extend these protections to the 16.5 million employees who work for contractors that do not have such policies. Exceptions could be crafted for the smallest contractors, for whom such policies may be too burdensome.

Mr. Obama deserves credit for his efforts to eliminate “don’t ask, don’t tell,” which prevented gay men and lesbians from serving openly in the military. He has rightly criticized the Defense of Marriage Act for withholding from same-sex couples federal benefits and responsibilities enjoyed by their heterosexual counterparts. He should continue on this path by issuing an executive order that makes clear that there should be no room for discrimination in the American workplace.