Under the bill, it would be legal to have 25 milligrams of heroin, a fifth of an ounce of marijuana or half a gram of cocaine. The bill also makes it legal to possess small amounts of LSD, hallucinogenic mushrooms, amphetamines and peyote.
President Vicente Fox had proposed the law in January 2004 in the hopes of slowing down the rapid growth in drug addiction and the ranks of small-time dealers that has hit Mexican cities and towns in recent years, just as it has long plagued American cities.
Both houses of the Mexican Congress passed it in a last-minute flurry of legislation as their session drew to a close. The final version of the bill passed the Senate by a vote of 53 to 26 during an all-night session that ended Friday morning. After its final approval, the president's spokesman, Ruben Aguilar, said Mr. Fox would sign it into law.
"This law gives police and prosecutors better legal tools to combat drug crimes that do so much damage to our youth and children," Mr. Aguilar said.
A United States Embassy official in Mexico deplored the new measure. "We have not seen the text, so we cannot comment on it in detail," said the official, who was not authorized to speak publicly. "But any law that would decriminalize dangerous drugs would not be helpful."
Supporters of the bill said it was meant to fix major flaws in Mexico's current drug laws. First, it will allow local judges and the police to decide on a case-by-case basis whether people should be prosecuted when caught with small amounts of drugs. Previously, every drug suspect had to be prosecuted, a system that put many addicts in jail while dealers went free after bribing officials.
Second, the state and local police will be empowered to arrest and prosecute street dealers who are carrying more than the minor amounts allowed under the law. Under existing laws, drug crimes were handled only by federal officials.
The new measure also requires people caught with less than the legal limits to go before a judge, prove they are addicts and seek treatment.
"We are not authorizing the consumption of drugs," said Senator Jorge Zermiño, the bill's sponsor in the Senate. "We are combating it and recognizing that there are addicts that require special treatment. We cannot close our eyes, nor fill our jails with addicts."
But opponents said the law would essentially legalize drug use and lead to more drug abuse and so help drug dealers.
"Here we are authorizing drug use," said Senator Miguel Ángel Navarro of the Party of the Democratic Revolution. "Whether it's a little or a lot, we are legalizing drug use. And I ask who is selling the drugs? Is it now legal to sell drugs in the eyes of the authorities? Clearly not."
The bill was approved as Mexico finds itself in the midst of a war between rival drug cartels that has claimed hundreds of lives, including dozens of police officers, particularly in the Texas border town of Nuevo Laredo and along the Pacific Coast between Acapulco and Zihuatanejo.
The violence has been only part of the social cost of the lucrative drug trade here. Twenty years ago Mexico used to be a country through which drugs passed on their way to Chicago, Los Angeles, New York and other major American cities.
These days, however, drug dealers and addicts have become more numerous in border towns and big cities. The growing local market for drugs has spurred higher levels of prostitution, robbery and burglary.
Local police forces have been hamstrung in their efforts to stop street-level dealing. Lacking the training and authority to investigate under the old law, they could arrest someone only if the person was caught in the act of selling drugs. Only the federal police could arrest someone for drug possession.
"The current law is unclear," said José Ángelo Cordova, the chairman of the health committee in the Chamber of Deputies. "If they don't catch the person selling it, they can't charge them with a crime."