Obama asked the Secretary of Health and Human Services to set up rules to make sure all hospitals that participate in the government-funded Medicare and Medicaid programs respect the rights of patients to designate who may visit them.

It should be made clear that designated visitors ... should enjoy visitation privileges that are no more restrictive than those that immediate family members enjoy, the memo said.

It said hospitals could not deny visitation privileges on the basis of sexual origin, race, religion or gender identity.

Every day across America, patients are denied the kindness and caring of a loved one at their sides -- whether in a sudden medical emergency or a prolonged hospital stay, Obama wrote.

He cited widows or widowers without children, members of religious orders as examples of people who have been unable to choose the people they want to be at their side in the hospitals that follow a relatives-only visitation policy.

Also uniquely affected are gay and lesbian Americans who are often barred from the bedsides of the partners with whom they may have spent decades of their lives -- unable to be there for the person they love and unable to act as a legal surrogate if their partner is incapacitated, he said.

Obama said he was taking the measures to expand visitation rights to ensure that patients can receive compassionate care and equal treatment during their hospital stays.

He also ordered hospitals participating in Medicare or Medicaid to ensure that all patients' advance directives, which include appointing someone to make healthcare decisions if necessary, are respected.

The memorandum was applauded by gay rights groups who have pushed to increase the visitation and decision making rights of same-sex partners.

Discrimination touches every facet of the lives of lesbian, gay, bisexual and transgender people, including at times of crisis and illness, when we need our loved ones with us more than ever, said Joe Solmonese, president of Human Rights Campaign, the largest U.S. gay rights group.

He said Obama's decision was inspired by publicity over a hospital's refusal to allow Lisa Pond to have her partner Janice Langbehn and their children at her bedside as she lay dying.

No one should experience what befell the Pond-Langbehn family, and the president's action today will help ensure that the indignities Janice and her children faced do not happen to another family, Solmonese said.

Obama has been under pressure from some gay activists who backed him for president in 2008 but were disappointed that he had not acted sooner on major gay rights issues.

In January he called for an end to the don't ask don't tell policy restricting gays from serving in the military.