WASHINGTON -- President Barack Obama on Monday signed an executive order banning workplace discrimination against millions of lesbian, gay, bisexual and transgender employees of federal contractors and the federal government.

The executive order has two parts: It makes it illegal to fire or harass employees of federal contractors based on their sexual orientation or gender identity, and it explicitly bans discrimination against transgender employees of the federal government. The part targeting federal contractors affects 24,000 companies employing roughly 28 million workers, or about one-fifth of the nation's workforce.

"America's federal contracts should not subsidize discrimination against the American people," Obama said during remarks at the White House just before signing the order. "I'm going to do what I can with the authority I have to act."

The provision affecting federal employees takes effect immediately, while employees of federal contractors will have their new protections in place by early next year, according to senior administration officials.

To the relief of the LGBT community, Obama did not include a sweeping religious exemption in the executive order -- something the community feared could happen in the wake of last month's Supreme Court ruling in the Hobby Lobby case.

Instead, Obama simply added the categories of sexual orientation and gender identity to an existing executive order that protects employees of federal contractors from discrimination based on race, color, religion, sex or national origin. President George W. Bush amended that executive order in 2002 to allow religiously affiliated federal contractors to prioritize hiring employees of their particular religion, however, and Obama is keeping that language intact.

Obama is fulfilling a 2008 campaign promise with his action targeting federal contractors. His action affecting federal employees, meanwhile, responds to what some have described as a shortcoming in existing governmental rules. The Equal Employment Opportunity Commission ruled in 2012 that the federal ban on sex discrimination covers transgender discrimination, but those affected by that rule change say the government hasn't been enforcing it and that they continue to be discriminated against.