WASHINGTON – Congress yesterday changed a 25-year-old law that has subjected tens of thousands of blacks to long prison terms for crack cocaine convictions while giving far more lenient treatment to those, mainly whites, caught with the powder form of the drug.

The House, by voice vote, approved a bill reducing the disparities between mandatory crack and powder cocaine sentences, sending the measure to President Barack Obama for his signature. During his presidential campaign, Mr. Obama said that the wide gap in sentencing “cannot be justified and should be eliminated.” The Senate passed the bill in March.