In a triumph for President Bush, the Senate approved groundbreaking education legislation Thursday, requiring annual math and reading tests of millions of school children as part of an effort to improve the nation's public schools.

The vote was 91-8, and set the stage for negotiations on a final compromise among the White House, the GOP-controlled House and the Senate, newly under Democratic management.

Final passage came after a bumpy, last-minute detour into the emotionally charged issue of the Boy Scouts and homosexuality.

On a vote of 51-49, the Senate approved a proposal by Sen. Jesse Helms, R-N.C., to strip federal funding from any school district that discriminates against the scouts or similar groups that "prohibit the acceptance of homosexuals." But opponents countered by winning swift approval of a proposal barring schools from denying access to any youth group, Boy Scouts included, on the basis of their views on sexual orientation.

The clash over the scouts provided a noisy conclusion to seven arduous weeks of debate in which senators in both parties agreed the legislation would mark a fundamental shift in the federal government's role in education.

Sen. Helms' amendment to the bill passed by a vote of 52-48. The House of Representatives approved a similar amendment last month.

The vote comes after the Supreme Court ruled last year that the Boy Scouts' ban on gay members and leaders is constitutional under the right to freedom of association.

Helms said his amendment was meant to combat "the organized lesbians and homosexuals in this country of ours." Democrats angrily denounced it, saying it would bind the hands of school boards trying to juggle access and scout sponsorship with their states' anti-discrimination laws.

"Think of the situation we are creating here," said Sen. Richard Durbin, D-Ill. "Imagine sitting on a school board, with no pay, under these circumstances ... I have to tell you: As I consider this amendment, it is a complete disaster."

The vote came after several hours of debate over the Boy Scouts' mission and history, complete with senators on both sides of the aisle fondly recalling their scouting days. Several Republicans stood to read or recite the Boy Scout oath.

"I have never been prouder in my entire political life than I am to stand here today with Senator Jesse Helms and support this amendment," said Sen. Bob Smith, R-N.H.

Democrats spoke in bitter opposition to the amendment, saying it was redundant in light of the Supreme Court's access ruling.

"I believe this amendment is unnecessarily gratuitous," said Sen. Barbara Boxer, D-Calif. "It's hurtful to a group of people — it divides us again in this country."

Senate Majority Leader Tom Daschle of South Dakota said the amendment would force school districts to make "a terrible choice."

"They could either disregard their own conscience or they could follow their conscience and lose millions of dollars that their schools and their children need," he said. "We believe in principled compromise, but we cannot compromise on the fundamental issues of civil rights."

According to the Boy Scouts of America Web site, about 3.4 million children were enrolled as Boy Scouts in 2000, a 1.2 percent drop from 1999.

The Associated Press contributed to this report