MANILA — The Philippines has enacted a law aimed at stopping the military and police officers from abducting people suspected of antigovernment activity, one of the ugly legacies of the country’s years of dictatorship.

The law, which President Benigno S. Aquino III signed late Friday, makes the “arrest, detention, abduction or any other form of deprivation of liberty committed by agents of the state” punishable by life in prison. It also holds superior officers liable for abductions committed by those under their command. Congress passed the legislation in October.

Human Rights Watch hailed the law, which it called “the first of its kind in Asia and a major milestone in ending this horrific human rights violation.” It was the first major human rights legislation signed by Mr. Aquino, who campaigned on promises of a better human rights climate but whose record since his election in 2010 has been seen as mixed by many rights groups.

The kidnapping of political opponents by security forces in the Philippines is a legacy of martial law, which was imposed during the 1970s by the dictator Ferdinand E. Marcos. During that period, the military, police officers and their agents abducted, tortured and sometimes murdered political opponents with impunity.