WASHINGTON (Reuters) - The United States on Thursday cut aid to Uganda, imposed visa restrictions and canceled a regional military exercise in response to a Ugandan law that imposes harsh penalties on homosexuality.

Uganda's President Yoweri Museveni signs an anti-homosexual bill into law at the state house in Entebbe, 36 km (22 miles) southwest of the capital Kampala February 24, 2014. REUTERS/James Akena

The White House said in a statement the measures were intended to “reinforce our support for human rights of all Ugandans regardless of sexual orientation or gender identity.”

Homosexuality is taboo in most African countries and illegal in 37, including in Uganda where it has been a crime since British rule.

Uganda’s new law, signed by President Yoweri Museveni in February, imposes jail terms of up to life for “aggravated homosexuality” which includes homosexual sex with a minor or while HIV-positive.

Widely condemned by donor countries, the law also criminalizes lesbianism for the first time and makes it a crime to help individuals engage in homosexual acts.

Western donors, including the United States, had halted or re-directed about $118 million in aid to the east African nation’s economy before Thursday’s announcement.

The White House said on Thursday the United States would impose visa restrictions on Ugandans it believes have been involved in human rights violations, including gay rights.

The United States will halt $2.4 million in funding for a Ugandan community policing program in light of a police raid on a U.S.-funded health program at Makerere University and reports of people detained and abused while in police custody.

In addition, Washington will shift some funding for salaries and travel expenses of Ugandan health ministry employees to non-governmental agencies involved in health programs.

It will also reallocate $3 million in funding for a planned national public health institute in Uganda to another African country, which it did not name. A National Institutes of Health genomics meeting would be moved from Uganda to South Africa, the White House said.

It also canceled plans for a U.S.-sponsored military exercise in Uganda that was meant to include other East African countries. A date had not yet been set for the exercise.

Uganda is a key Western ally in the fight against Islamic extremism in Somalia, where Ugandan troops for the backbone of the African Union force battling al Qaeda-aligned militants.

U.S. special forces have also been involved in the hunt for Joseph Kony, the elusive rebel commander seeking to topple the Ugandan government. Kony is believed to be hiding in the jungles of central Africa.

In Kampala, a government official asked about the U.S. measures said that Uganda would not alter its decision to toughen laws against homosexuals.

“Uganda is a sovereign country and can never bow to anybody or be blackmailed by anybody on a decision it took in its interests, even if it involves threats to cut off all financial assistance,” government spokesman Ofwono Opondo said.

U.S. President Barack Obama previously told Museveni the law would complicate relations between the two countries. Since then Washington has been reviewing its funding to Uganda, while privately pressing Museveni’s government to repeal the law.