WASHINGTON—The Democratic-controlled House passed a broad package of measures intended to reduce gun violence, while parents and other witnesses shaken by mass shootings in their communities beseeched lawmakers at a congressional hearing to act to prevent further deaths.

The House bill, approved 223 to 204 largely along party lines, pulls together a series of gun measures that have backing in the Democratic Party but little support among Republicans, making the proposal a nonstarter in the evenly split Senate, where 60 votes are required to advance most legislation. Senate negotiators are working on a narrower set of proposals, centered on school security, supporting state red-flag laws and adding juvenile records to background checks, to keep guns out of the hands of potentially dangerous people.

The House gun bill, called the Protecting Our Kids Act, would raise the age for purchasing semiautomatic rifles and shotguns to 21 from 18. It also would require gun owners to store their guns so that minors can’t access them without permission, imposing as many as five years in prison if a child accesses an unsecured gun and kills or hurts someone.

Miah Cerrillo, a fourth-grader who survived the mass shooting at a school in Uvalde, Texas, by playing dead, addressed lawmakers Wednesday.

Photo: Jason Andrew/Press Pool

The bill would make it a federal crime to engage in straw purchases—the buying of a gun for someone else—or gun trafficking, which is the illegal trading of guns. It also would ban licensed dealers from selling guns with magazines that can hold more than 15 rounds of ammunition. And it would ban devices known as bump stocks, which make semiautomatic rifles shoot like rapid-fire machine guns, putting into law a regulatory ban.

The vote was spurred by mass shootings at an elementary school in Uvalde, Texas, and a grocery store in Buffalo, N.Y., in the span of two weeks. Both of the alleged shooters were 18-year-old men. One girl who managed to escape death in Uvalde testified before a House panel on Wednesday, describing how she had watched a gunman kill her classmates. The mothers and fathers of other shooting victims testified before the House Oversight Committee about the anguish of losing their children or caring for their wounds.

“He shot my friend that was next to me,” testified Miah Cerrillo, a fourth-grade student, who played dead to avoid being targeted. “I thought he was going to come back to the room, so I got her blood and put it all on me.”

“I don’t want it to happen again,” she said.

Kimberly Mata-Rubio, the mother of a student killed in Uvalde, said she replayed in her mind the moment she dropped her daughter off at school, a decision that “will haunt me for the rest of my life.”

“Somewhere out there, there’s a mom listening to our testimony, thinking I can’t even imagine their pain,” Ms. Mata-Rubio said. “Not knowing that our reality will one day be hers. Unless we act now.”

More than 45,000 people suffered firearms-related deaths in 2020, according to the New England Journal of Medicine, based on an analysis of data from the Centers for Disease Control and Prevention. Firearm deaths are now the leading cause of death for people from ages 1 to 19.

The House last year passed bills to expand background checks to nearly all gun sales and to extend the window for background checks to 10 days from three days, but those haven’t been brought up for a vote in the Senate.

On Wednesday, five Republicans joined most Democrats to vote in favor of the final bill, while two Democrats voted against it. The Republicans who crossed party lines included Rep. Chris Jacobs (R., N.Y.), who represents an area near Buffalo. In the wake of the supermarket shooting, he came out in favor of banning assault-style weapons and raising the age for some gun purchases. After criticism from his party, he announced he wouldn’t seek re-election.

SHARE YOUR THOUGHTS

Where do you think Democrats and Republicans can find agreement on a gun- control package? Join the conversation below.

Most Republicans opposed the package, saying the bill would deprive Americans of their constitutional right to bear arms and their ability to use firearms in self-defense, and do little to stop criminals.

Wednesday’s votes are “designed to advance the radical Democrat base that believes no private citizen should ever be able to own a gun,” said Rep. Michelle Fischbach (R., Minn.).

“None of these proposals are aimed at taking guns away from law-abiding citizens,” said Rep. Jim McGovern (D., Mass.). “They are aimed at stopping people from getting slaughtered in their schools, in their churches, in grocery stores and in their homes.”

In the Senate, the lead Democratic negotiator, Sen. Chris Murphy

of Connecticut, said that he was satisfied with the talks so far and that lawmakers were aiming to pull together the package by the Fourth of July holiday break.

“I know that the urgency often fades, but there’s something different happening out there in the country right now,” he said.

A small group of Senate negotiators—made up of Republican Sens. John Cornyn of Texas and Thom Tillis of North Carolina, along with Mr. Murphy and fellow Democrat Sen. Kyrsten Sinema of Arizona—met with a larger bipartisan group Wednesday to brief them on negotiations.

Mr. Tillis told reporters there is a good chance negotiators could agree on a framework by the end of the week.

Mr. Cornyn, the top GOP negotiator, said he was pleased by the progress both sides were making.

“We all understand the differences that we have regionally, culturally when it comes to things like the Second Amendment,” he said. “It doesn’t make it easy, but it makes it possible for us to try to find some common ground.”

While mental-health funding has been a major focus, a handful of Republicans have said they would be willing to explore raising to 21 the age for buying certain assault-style weapons such as an AR-15.

“That I would consider,” said Sen. Joni Ernst (R., Iowa).

Write to Siobhan Hughes at siobhan.hughes@wsj.com