The Maryland General Assembly has passed legislation to expand protections for transgender individuals, barring employers, landlords and others from discriminating against people based on gender identity.

The House of Delegates voted 82 to 57 on Thursday to give transgender individuals the same protections given to those who might face discrimination based on race, sex, color, creed, national origin, marital status, sexual orientation, age or disability.

The Senate has already approved the civil rights legislation, and Gov. Martin O’Malley (D) said he looks forward to signing it into law.

The House also approved a $39 billion state budget for the next fiscal year, including a provision that would allow the state to seize property of film production companies that receive more than $10 million in tax credits and then leave the state — as the Netflix series “House of Cards” has threatened to do. The Senate has approved a similar budget but differences between the two will have to be reconciled.

Lawmakers have fought over whether to pass a bill protecting transgender individuals for more than seven years. The battle culminated Thursday in an intense and often emotional debate. After the House vote, the senator and delegates who sponsored the legislation hugged on the chamber floor.

“People realized that no one should be denied a job, should be thrown out of their home, should be denied a place to eat dinner just for living a life as who they are,” said Sen. Richard S. Madaleno Jr. (D-Montgomery), who has championed the protections. He is gay and is running for reelection against Dana Beyer, a transgender woman.

The Fairness for All Marylanders Act of 2014 bans discrimination based on gender identity in employment, housing and public places, which includes hotels, restaurants, theaters and sports venues. It includes an exemption for religious organizations, private clubs and educational institutions. Sixteen other states and the District have enacted similar legislation.

More than a dozen delegates — including some Democrats — argued against the legislation on Thursday. They called the legislation the “Bathroom Bill,” as it would allow a person who was born male to use women’s restrooms if that person identifies as female.

Opponents said that practice could endanger women and girls who are using the bathroom. Supporters, however, said transgender people are often ridiculed and sometimes assaulted when they use restrooms assigned to the genders of their birth.

The chamber was unruly, with some opponents of the bill cracking jokes about transgender people and Del. Neil Parrott (R-Washington) citing the Bible as he proclaimed that God made men as men and women as women.

“We can pass all the bills we want, but we cannot change nature; politics cannot change nature,” said Del. Emmett C. Burns Jr. (D-Baltimore County). “My constituents think we have lost our minds.”

Del. Kathy Szeliga (R-Harford) unsuccessfully proposed an amendment that would have excluded bathroom facilities from the list of public places where discrimination is prohibited, saying, “Please protect women, protect little girls.”

Del. Joseline A. Pena-Melnyk (D-Prince George’s), one of dozens of lawmakers who backed the bill, was tasked with responding to objections. She said she studied for weeks and practiced answers with the help of Del. Luke H. Clippinger (D-Baltimore), the lead sponsor of the original House version of the legislation.

While Pena-Melnyk stayed calm through hours of sparring, some of her colleagues grew frustrated, accusing opponents of the bill of lacking tolerance. Several said the struggle of the transgender community for civil protections was comparable to past struggles of African Americans, gays and religious minorities.

They did not come close to persuading Del. Kevin Kelly (D-Allegany), who said that if he saw a person whom he thought to be a man follow his 7-year-old daughter into “the little ladies’ room” at a restaurant, he would confront that person. Under the new legislation, Kelly said, he would probably be the one in the wrong.

“Subjectively, in their little mind, they are” female, Kelly said, twirling his finger near his ear in a gesture that usually implies someone is insane. “In my objective mind, I’m looking at him and saying, ‘That’s the wrong person to be in there.’ ”

At that point, Del. Heather Mizeur (D-Montgomery), who is running for governor, rose to her feet. “I’ve never been more disappointed in the conduct of our conversation on the House floor,” she said, eliciting some boos.

“The underlying issue in this legislation is whether or not some of our most vulnerable members of society are still allowed to get beat up in these bathrooms,” said Mizeur, who is gay. “We are talking about people who are suffering real harm in this state.”