LILONGWE, MALAWI — If this small nation, with a per capita income of less than $3 a day and a life expectancy of 53, offers a hopeful model for fighting the scourge of AIDS in Africa, then large and relatively prosperous Uganda shows how quickly progress can run off track.

Secretary of State Hillary Rodham Clinton saw Malawi’s more promising example Sunday as part of an eight-nation African visit. Last week in Uganda, she highlighted an alarming rise in infection rates there after years when the country was a leader in preventing the spread of HIV and AIDS. About 23 million people in sub-Saharan Africa are believed infected, and the United Nations has estimated that the region had 1.2 million AIDS-related deaths in 2010.

“I am here because I am worried,” Clinton said Friday during a tour of a health center near the Ugandan capital, Kampala, that treats women with HIV and AIDS.

“In recent years, the focus on prevention has faded, and new infections are on the rise again,” she said. “Uganda is now the only country in sub-Saharan Africa where the rate is going up instead of down.”

The number of Ugandans with HIV doubled between 2004 and 2011, from 1.2 million to 2.4 million. A more blase attitude about AIDS among Ugandans is one explanation, and a more socially and religiously conservative approach to the epidemic from the government of Yoweri Museveni may be another.

By contrast, Malawi has a higher infection rate but a more progressive approach to countering it. Clinton said little about the epidemic during a one-day visit here Sunday. But her very presence as the first U.S. secretary of state to visit Malawi was a mark of regard for the new government of President Joyce Banda, a women’s rights activist who has backed aggressive HIV-prevention programs.

Clinton toured an educational summer camp for girls run by the Peace Corps, where the curriculum includes sexual health and birth control. Later, Clinton’s party bumped down a long dirt track to a U.S.-sponsored milk-production cooperative where farmers can also be tested and treated for HIV.

U.S. officials say about one in 10 Malawians is infected with HIV or has AIDS, a crippling figure. But the rate has fallen from 13 percent over five years, and innovative prevention and treatment programs extend through much of the country. Malawi has cut mother-to-child transmission of the virus, condom use is widely accepted, and a male circumcision program once unthinkable in this traditional society is now oversubscribed.

U.S. officials point to a huge change in public attitudes and awareness over the past decade. In 2002, Malawi suffered the worst famine in 50 years, caused in part by the absence of farmers who were too sick to work or who were caring for sick relatives.

“The government is committed,” said Ritu Singh, who heads HIV and AIDS work in Malawi for USAID. “They understand this is a problem, and they understand this is affecting their people.”

The challenges remain vast, even leaving aside Malawi’s poverty. Per capita income is about $900, more than half the population is dependent on outside aid, and U.S. donations fund the majority of Malawi’s annual health budget.

Cultural norms contribute to HIV transmission, including an acceptance of multiple sex partners, polygamy and rituals such as sexual “cleansing” of recently widowed women, said Beth Deutsch, a longtime U.S. government HIV specialist in Malawi.

Condoms are not a tough sell generally. But condom use carries a stigma for married couples and others in trusted relationships, even though those relationships may not be monogamous, Deutsch said. The availability of condoms where they are needed is a major challenge.

Uganda has many parallel difficulties, but until recently it was widely praised for a national effort to put prevention and treatment ahead of even the deeply held cultural aversion to frank public discussion of sexual behavior and homosexuality.

Success in treating infection, much of it funded by more than $1.6 billion in U.S. aid over the past six years, has allowed even very poor Ugandans to live normal lives. But that success has had unintended consequences: It has reduced the perception of risk and made a positive diagnosis a source of badly needed general medical care, AIDS advocacy groups say.

Clinton said she discussed the backslide with Museveni, a close U.S. partner in counterterrorism and African security missions, and she made a point of praising Ugandan activists who opposed efforts to criminalize homosexuality.

Although HIV is mostly spread through heterosexual sex in Africa, AIDS groups said a proposed anti-homosexual law would set back prevention efforts by driving risky gay sexual behavior underground.

Draft legislation introduced in 2009 proposed the death penalty for anyone convicted of “aggravated homosexuality.” The bill stalled in parliament, but a milder version was reintroduced by a member of Museveni’s party.

“It is critical for all Ugandans — the government and citizens alike — to speak out against discrimination, harassment and intimidation of anyone,” Clinton said in presenting a human rights award to a coalition of activist groups. “That’s true no matter where they come from, what they believe or whom they love.”