WASHINGTON (CN) — On the last day before August recess, the House passed legislation that would ban assault-style guns, a move that comes on the heels of several brutal mass shootings.

The bill passed the chamber by a margin of 217-213, with two Republicans voting in favor of the ban and five Democrats breaking with their party to oppose the bill.

It’s the first House vote on assault weapons since 1994, when Congress passed a bill that outlawed high-powered assault rifles. That ban expired in 2004 and efforts since then to regulate and ban the firearms have repeatedly failed.

The legislation would ban the sale or production of semi-automatic rifles and shotguns that have at least one “military-style feature,” such as a grenade launcher, a pistol grip or a fixed magazine that can hold more than 10 rounds of ammunition.

Bump stocks, which can be attached to firearms to speed up the rate of fire, as well as high-capacity ammunition feeding devices and magazines are also outlawed under the bill.

People who already legally own assault-style weapons would not be affected by the ban, which would only apply to future gun sales, and gun sellers would be required to conduct background checks before selling or transferring semi-automatic weapons that were legally owned prior to the legislation’s enactment.

The legislation faces little chance in the 50-50 Senate, and it barely squeaked its way through the House, but it still marked a win for Democrats, who have faced increasing pressure to act on gun control in the wake of recent devastating mass shootings.

AR-15 style guns were used by the shooter who murdered 10 people at a grocery store in Buffalo, New York, and the shooter who gunned down 19 children at an elementary school in Uvalde, Texas earlier this summer.

Democratic Representative David Cicilline of Rhode Island, who sponsored the ban, said semi-automatic firearms like the AR-15 are “weapons of war.”

“The military features banned by this bill are added to make these guns more accurate, more controllable or concealable and more deadly, enabling killers to murder as many people as possible as quickly as possible. These weapons have no place in our communities. They turn our streets, our schools, our grocery stores, our movie theaters and hospitals into bloody battlefield scenes. And they kill our children, our friends and neighbors, and the police officers trying to protect them,” Cicilline said on the House floor Friday.

An investigation by the House Committee on Oversight and Reform earlier this week revealed that in the past decade, gunmakers have made more than $1 billion from the sales of AR-15 style guns.

Two major gun manufacturers, Daniel Defense and Sturm, Ruger & Co., saw their revenue from the weapons triple in just the past three years, according to the committee’s report.

“All those who have had the privilege of serving in these hallowed halls take a solemn oath to the American people. At the heart of our oaths is our duty to protect and defend, protect and defend the Constitution and the American people. With this legislation, we honor this foremost responsibility,” Speaker of the House Nancy Pelosi said on the House floor.

Several Republican lawmakers, including Representative Jim Jordan of Ohio, condemned the assault weapons ban, claiming it violated the Second Amendment.

“They’re taking away firearms used for self-defense by law-abiding Americans. This bill is wrong,” Jordan said on the House floor Friday.

GOP Representative Chip Roy of Texas called the legislation unconstitutional and tyrannical.

“My colleagues will most assuredly target citizens to take their guns,” Roy said, although the legislation does not apply to assault-style weapon that are already legally owned.

Last month, both chambers of Congress passed the first major gun safety legislation in 30 years on a bipartisan basis.

The bill provided millions of dollars for mental health programs, expanded background checks for gun purchasers under the age of 21 and aimed to close the “boyfriend loophole,” by including dating partners in a federal law that bans people convicted of domestic violence against a spouse or living partner from purchasing a firearm.