BOSTON - Ten years after George W. Bush defeated Al Gore for president despite losing the popular vote, Massachusetts is close to joining a handful of other states in passing a law that would try to prevent such a twist from happening again.

The Massachusetts Senate approved a bill, 28 to 9, Tuesday that would assign the state's electoral votes to the presidential candidate who won the national popular vote -- regardless of whom Massachusetts voters preferred.

The House passed the legislation last week, and Gov. Deval Patrick has suggested that he would sign it.

The five states that have already enacted such laws -- Hawaii, Illinois, Maryland, New Jersey and Washington -- account for only 61 electoral votes. Massachusetts would add 12, bringing the total number of electoral votes based on the national popular vote to 73.

Once states accounting for a majority of the electoral votes -- 270 of 538 -- have enacted the laws, the candidate winning the most votes nationally would be assured a majority of Electoral College votes. That would hold true no matter how the other states vote.

Presidential candidates have won elections three times despite losing the popular vote.

Supporters of changing the system say the current Electoral College system is confusing and causes presidential candidates to focus unduly on a handful of battleground states.

"What we are submitting is the idea that the president should be selected by the majority of people in the United States of America," said Senator James Eldridge, an Acton Democrat. Under the new bill, he said, "Every vote will be of the same weight across the country."

Presidential candidates now "ignore wide swaths of the country" they consider strong blue or red states and focus their campaigning on contested states, Eldridge said. If the president were picked by national popular vote, he argued, candidates would spread their attention out more evenly.

But Senate minority leader Richard Tisei said the state was meddling with a system that was "tried and true" since the founding of the country.

"We've had a lot of bad ideas come through this chamber over the years, but this is going to be one of the worst ideas that has surfaced and actually garnered some support," said Tisei, who is also the Republican candidate for lieutenant governor.

He said the legislation would force candidates to focus on cities, where they can get the most votes. "They're going to spend all their time in New York City and Los Angeles," he said, "and to hell with the rest of the country."

Opponents also point to the disturbing scenario that Candidate X wins nationally, but Candidate Y has won in Massachusetts. In that case, all of the state's 12 electoral votes would go to Candidate X, the candidate who was not supported by Massachusetts voters.

Tisei also criticized the proponents for not following the normal procedures to seek a constitutional amendment.

He said, "The thing about this that bothers me the most is it's so sneaky. ... This is sort of an end run around the Constitution."

The Boston Globe contributed to this report.