Partygoers react at an Election Night party in Baltimore after voters passed a referendum approving same sex marriage in Maryland. (Patrick Semansky/AP)

Voters in the Washington suburbs were instrumental in the passage of Maryland ballot measures for same-sex marriage and in-state tuition for undocumented immigrants, and they were a bastion of support for the expansion of gambling.

A Washington Post analysis of census and voting data shows marked differences in support for the three referendum questions. The precinct-by-precinct analysis shows that the state was as divided as the country is on some issues, varying by race and ethnicity, income and geography.

Votes in favor of gay marriage, for example, were concentrated in Montgomery and Howard counties as well as in and around Baltimore. The measure won in precincts that are predominantly white or so diverse that no racial or ethnic group predominates. Support was highest in neighborhoods where the median household income tops $180,000.

Conversely, the gay marriage question failed, although by small margins, in precincts that are predominantly black or Hispanic and in the exurbs and rural stretches of the state. It lost in most parts of socially conservative, affluent Prince George’s County and in neighborhoods where the median household income dips below $50,000.

The Dream Act measure, granting in-state tuition to the children of immigrants who did not come to this country with proper documents, passed handily in almost all neighborhoods except those that are largely non-Hispanic white. It won in white precincts in the suburbs around Washington, however.

Demographic support of Maryland ballot measures

And the measure that expanded gambling was supported broadly across the state, faltering only in some of the state’s more rural reaches.

Del. Neil Parrott (R-Washington County), who led online petition drives to bring several measures before voters, said the analysis shows how the ballot questions transcended traditional political boundaries.

“Prince George’s County was strongly for Obama, yet it came out against changing the definition of marriage,” he said. “Anne Arundel County was pro-Romney, and it went for changing the definition of marriage. What we see are people voting values that don’t necessarily match up with what their party affiliation is.”

Exit polling done in Maryland on Election Day showed that same-sex marriage was overwhelmingly supported by voters younger than 40 and rejected by every other older group of voters. It won among white men and women and among black women, but it was rejected by black men. Voters who are college graduates, liberal, unmarried, high-income and do not regularly attend religious services were far more likely to support gay marriage than voters who are conservative, have incomes below $100,000 or are weekly church-goers.

Both opponents and proponents of legalizing same-sex marriage pointed to advertising as key to the outcome.

“We made significant inroads in the African American vote,” said Kevin Nix, a spokesman for Marylanders for Marriage Equality, which promoted same-sex marriage. “Though it did come up a little short, I think there was significant progress made in Prince George’s and the Baltimore area.”

Nix cited ads touting the support of prominent voices in the African American community, such as the Rev. Delman Coates of Mount Ennon Baptist, the megachurch in Prince George’s, and the Rev. Donte Hickman Sr., pastor of Southern Baptist Church in East Baltimore. The measure also was supported by the NAACP in Prince George’s and President Obama.

“As our opponents said, we inundated the airways with messages of equality,” Nix said. “Our message got through. That’s why our numbers shifted.”

In early spring, support for same-sex marriage hovered around 40 percent. Ultimately, it won almost 52 percent of the vote. The Post’s analysis shows that its strongest support came from white and diverse neighborhoods in the Washington suburbs. Even in predominantly black and Hispanic precincts, where it lost, it got 47 percent of the vote.

Derek McCoy, chairman of the Maryland Marriage Alliance, said many voters who believe marriage is only between a man and a woman voted in favor of same-sex marriage. He attributed it to ads promoting marriage equality, portraying it as an issue of fairness. Several, he said, cited the support of the president and first lady Michelle Obama.

“The message of civil rights resonated,” he said, citing its passage in the city of Baltimore, which is 64 percent black.

“But you have a very divided state on this issue,” he added. “I don’t think it shows, in no way shape or form, that people are overwhelmingly in support of the issue. They spent $6 million and threw in everything . . . including the president, in order to slightly sway people on this issue.”

The ballot measure granting in-state tuition to the children of illegal immigrants drew widespread support in every type of precinct across the state except those in predominantly white neighborhoods. Statewide, voters in white precincts opposed it by 52 percent.

In the Washington suburbs, however, it drew 54 percent of the vote in predominantly white neighborhoods, compared with 82 percent in Hispanic precincts and 76 percent in black precincts. That was more than enough to offset the opposition to it in exurban and rural precincts, where barely a quarter of all voters live.

The gambling question won popular support in large swaths of the state, including most of the Washington region. It lost, however, by narrow margins in parts of Montgomery County, including Silver Spring, Takoma Park, Chevy Chase and areas of Bethesda.

Valerie Ervin, the Montgomery County Council member who represents some of the areas where expanded gambling was rejected, said she was not surprised by the vote.

“That community has never supported gambling, going way back,” she said. “They see it as a tax on the poor. It’s a very progressive area of the county.”