After weeks of arduous negotiations between House leaders, President Trump and divided moderate and conservative GOP lawmakers, the House of Representatives voted to repeal and replace the Affordable Care Act, setting the stage for another lane of hurdles that must be cleared in the Senate.

The highly partisan vote was 217-213.

From the floor of the chamber, House Speaker Paul Ryan immediately before the vote praised Trump for his "steadfast leadership" over recent weeks in helping negotiate the compromises necessary to secure enough votes for passage. 

The bill will provide a simpler more affordable way to provide health coverage even as insurers are pulling out of the exchanges set up by Obamacare, Ryan said.

"We can continue with the status quo or make it easier to offer health insurance," he said.

The new plan will provide more individual control and piece of mind for patients, he said.  "Let's put the patient, not the bureaucrats, at the center of the system," he said.

Ryan acknowledged the long-running GOP efforts to build public opposition to the ACA and noted that many in office today were elected due to conservatives' opposition to what was President Obama's signature legislative achievement.

"Many of us have wanted seven years to cast this vote," he said. "Many of us are here because of our pledge to cast this vote."

On the other side of the fight, Democratic leader Nancy Pelosi followed other speakers with an impassioned call to vote against the bill, which she suggested will make its supporters radioactive when voters grasp that it will cause higher deductibles and premiums and reduced coverage. She repeated the Democrats' contention that more than 20 million Americans will lose coverage with the elimination of the Affordable Care Act.

"You will glow in the dark with this one," she warned in the final minutes before the vote.

She derided Republicans' contention that the bill will fix the shortcomings of Obamacare.

"Speaker Ryan called this bill an act of mercy -- an act of mercy. There is no mercy here," she said.

Also Pelosi said, "Affordable health care is a civil right, a fundamental right of everyone in our country, not just a privileged few."

The outcome of the vote was not known until early Thursday. Republican leaders could afford to lose only 22 votes from their party and still have the measure past. Polls of GOP members indicated that the opposition, once strong enough to stop the bill, dwindled to 15.

Ultimately, the margin was much closer than House leaders would have liked--20 Republicans voted "no."

After weeks of grueling negotiations, Ryan received a standing ovation after addressing the GOP conference Thursday morning.

A critical change to win over GOP moderates in the past 24 hours was Trump's agreement to provide an additional $8 billion to some states to reduce costs for covering individuals with pre-existing conditions.

On Wednesday Rep. Fred Upton, R-Mich., and Rep. Billy Long, R-Miss., dropped their opposition and agreed to vote for the bill after winning Trump's backing for their amendment providing for an additional $8 billion over five years to help states that have waivers allow insurers impose higher premiums on individuals with pre-existing conditions. Under Obamacare charging those individuals more is forbidden.

Another new amendment from Rep. Tom MacArthur of New York that helped keep conservatives' support would let states apply for waivers from some of the health law's insurance requirements.

At the last minute Ryan pulled the original health care overhaul from floor consideration in March because it lacked the votes to pass.

Should the legislation be enacted, the biggest beneficiaries among public companies are likely to be the largest health insurers, including Anthem (ANTM - Get Report) , UnitedHealth (UNH - Get Report) , Cigna (CI - Get Report) and Humana (HUM - Get Report) .

Hospital stocks such as Tenet Healthcare (THC - Get Report) , Community Health (CYH - Get Report) , HCA (HCA - Get Report) and LifePoint Hospitals (LPNT are likely to suffer from cuts to health care providers' revenue.