Above: Jr. Velez, 21, puts his arm around his little brother while walking with his AR-15 rifle down a Houston street July 4, 2013, as they joined a group of more than 20 people with the pro-gun organization, Come and Take it Houston, as part of a rally to educate people about local gun laws.

Texas is a hair’s breadth away from legalizing the licensed open carry of handguns after the state Senate late Friday approved the legislation following hours spent arguing over a controversial amendment that would limit cops’ ability to detain gun owners, the Houston Chronicle reported.

The Senate approved House Bill 910, which would allow properly licensed gun owners to openly carry their handguns in shoulder or hip holsters. The bill passed by a final vote of 19-12 and now heads back to the House, where that chamber’s members will have to agree with the Senate’s changes.

Debate was prolonged late into the evening after Dallas Republican Don Huffines proposed an amendment that would bar police from stopping someone solely for openly carrying a handgun in public. The amendment was adopted and passed as part of final bill.

The emotional, heated and often personal debate was an unusual turn of events in the Senate, in which debate is normally highly scripted. An unusual coalition of Democrats and some Republicans banded together to oppose the amendment, saying it would tie the hands of law enforcement and put the public in danger.

“I’m not sitting down until I have made my point that this is a mistake,” said Houston Republican Joan Huffman, a former prosecutor and judge. “With certain rights come responsibilities, and there has to be some social order.”

John Whitmire, a Houston Democrat and longest-serving state senator, said he thought the amendment essentially would legalize unlicensed open carry of handguns, which advocates call “constitutional carry.”

“This is nothing but a backhanded way to accomplish constitutional carry,” said Whitmire. “We are really, really playing with a dangerous matter. It’s not something that we can afford to be wrong about.”

Sen. Rodney Ellis, D-Houston, has consistently voted against expanding gun rights in Texas and said he has worn his low National Rifle Association score as “a badge of honor for the past 25 years.” But he supported Huffines’ amendment Friday to discourage racial profiling for African-American Texans who decide to open carry under the new law.

“If I could kill my distinguished colleague’s bill, I would do that,” Ellis said. “If somebody is going to be profiled over walking around the streets of Houston or Austin with a gun, in my mind, I think somebody who looks like me is more apt to get stopped than somebody who looks like you.”

Many law enforcement groups, including the Combines Law Enforcement Association of Texas, the state’s largest police organization, are staunchly opposed to Huffines’ amendment.

In a statement, Lt. Gov. Dan Patrick applauded the bill’s passage, saying: “With time running out on this legislative session, the Senate has once again stood up for the Second Amendment to ensure law-abiding licensed Texans have the right to open carry.”

Patrick said House Speaker Joe Strauss has assured the Senate that the House will approve a campus carry bill before time runs out on the legislative session.

Leadership in both chambers on Friday confirmed the House will allow debate on so-called “campus carry” legislation. If passed, it would allow properly licensed firearms owners to carry concealed handguns into college and university buildings.

Similar campus carry legislation passed in 2013 but contained a provision that would allow campuses to opt out. House Democrats promised to fight the bill when it reaches the floor.

“Nothing changes for me. I will continue fighting against campus carry and will lead that fight with my use of the rules and effective floor strategy,” said Trey Martinez Fischer, D-San Antonio. “This fight is far from over.”