Maine voters on Tuesday repealed a state law granting same-sex couples the right to marry, defeating an effort by gay activists who hoped the state would become the first to approve gay marriage at the polls.

Nearly 53 percent of voters opted to throw out a same-sex marriage law passed by the state Legislature in May, while 47 percent voted to uphold it, with 87 percent of precincts reporting early Wednesday morning.

The vote in Maine was being closely watched by both supporters and opponents of gay marriage across the country one year after voters in the most populous state, California, passed a constitutional amendment banning same-sex marriage. Only five states currently allow same-sex marriage.

As voters went to the polls on Tuesday, gay marriage advocates were emboldened by what appeared to be higher than expected turnout in Maine. Even before polls opened on Tuesday roughly one-tenth of the state’s registered voters submitted mail-in ballots or voted early.

And in an interview late Tuesday night on MSNBC, Maine Democratic Gov. John Baldacci said that at polling places it looked like “the presidential election all over again.”

“A lot of young people were showing up, a lot of first-time voters were showing up,” Baldacci said. “I was encouraged by that.”

Supporters also hoped money would make a difference in the outcome. The main group working to keep the state’s marriage law on the books, Protect Maine Equality, outraised the leading opposition group, Stand for Marriage, by more than $1 million.

Gay marriage supporters were looking to make Maine the sixth state — in addition to Iowa, Massachusetts, Vermont, New Hampshire and Connecticut — to legalize same-sex marriage.

In Washington state, voters also were poised to decide whether to endorse the state’s “everything but marriage” law, which would give gay and lesbian couples more of the rights that married couples now enjoy.

In all, 26 measures appeared on the ballot in six states on Tuesday, making 2009 one of the slowest years for ballot initiatives in the past decade, according to the National Conference of State Legislatures.

Residents of several large cities — including New York, Atlanta, Detroit, Houston, Miami, Pittsburgh and Seattle — also went to the polls on Tuesday to choose mayors.

New York Mayor Michael Bloomberg won an unexpectedly tight race Tuesday night with long-shot challenger City Comptroller William Thompson Jr. — a contest that was so close that NBC initially called the race for Bloomberg, then withdrew its call.

After running the most expensive self-financed campaign ever, Bloomberg was expected to cruise to a third term over Thompson. But as the night wore on, the results stayed close, with Bloomberg eventually prevailing by a 51 percent to 46 percent margin. Bloomberg, an independent who also ran on the Republican line, spent more than $85 million of his personal fortune to win reelection.

In Boston, Mayor Thomas Menino defeated City Councilor at Large Michael F. Flaherty to win a record fifth term, by a margin of 57 to 42 percent. Menino, who took office in 1993, is the city’s longest-serving mayor.

Luke Ravenstahl, the 29-year-old mayor of Pittsburgh, won his first full term outright, winning 55 percent of the vote and fending off challenges from two independent candidates. Ravenstahl was appointed to the post in 2006 following the death of former Mayor Bob O'Connor.

In Atlanta, City Council member Mary Norwood, who was vying to become the city’s first white mayor since the 1970s, appeared headed for a run-off with former state legislator Kasim Reed. Norwood won 43 percent of the vote to Reed’s 38 percent. A third candidate, City Council President and businesswoman Lisa Borders, won 14 percent. Since no candidate received a majority, Norwood and Reed will advance to a Dec. 1 runoff.

Tomas Regalado, a Miami city commissioner and former television reporter, easily defeated fellow commissioner Joe Sanchez, by a 72 percent to 28 percent margin, to become that city’s next mayor, replacing the current mayor, Manny Diaz, who is term limited.

In Detroit, Mayor Dave Bing, a former basketball player, won reelection 58 percent to 42 percent over challenger Tom Barrow, an accountant. Bing was elected mayor in a May special election after former Mayor Kwame Kilpatrick pleaded guilty to obstruction of justice charges in a scandal involving his relationship with a top aide.