The end has come for Rikers Island.

The City Council on Thursday approved Mayor Bill de Blasio’s polarizing plan to shutter the scandal-scarred complex by 2026 and replace it with four smaller borough-based jails – but not without plenty of pushback from pols and community activists.

The $8.7 billion project surpassed the 26 votes needed for approval Thursday, thus bringing new high-rise lockups to every borough but Staten Island.

The four new jails are slated to be built on the site of the NYPD’s Bronx tow pound, at the now-closed Queens Detention Center in Kew Gardens and at the current sites of the Brooklyn Detention Complex in Boerum Hill and Manhattan Detention Complex in Lower Manhattan.

The Brooklyn, Queens and Manhattan portions of the plan each passed by tallies of 36 – 13, while the Bronx part passed 35 – 14.

Bronx Councilman Rafael Salamanca Jr., a Democrat, voted against the new Bronx facility because he first wants Mayor de Blasio to close the Vernon C. Bain Center, a jail barge floating in his borough.

Two members of the 51-member council were not present for the votes.

Council Speaker Corey Johnson said he backed the overall plan because Rikers has been “a stain on New York City” for decades.

“We are closing a penal colony in the East River that symbolizes inhumanity and brutality,” he said. “We cannot solve all the world’s problems in today’s vote … but we are doing something very, very significant today.”

Councilwoman Karen Koslowitz, who represents the area where the new Queens jail will go up, said this was the “hardest vote” she’s made on the council because of backlash she received from constituents. However, she said she ultimately backed the plan because closing Rikers is the “humane thing to do” and allows her to “sleep very well” at night.

She claimed inmates at Rikers are “treated like animals, and it has to stop.”

However, Councilman Steven Matteo (R-Staten Island) said he voted against the plan because it’s “ill-conceived” and “extremely costly.”

“It is contingent upon further reducing a jail population, which, by the administration’s own admission, is already filled with serious and violent offenders,” Matteo said. “Thus, it will require putting more potentially dangerous offenders back on the street, jeopardizing public safety.”

Councilman Robert Holden (D-Queens) agreed, saying “the closing of Rikers Island has become a religious movement, a symbol of criminal justice reform that will not actually solve the justice system’s problems.

“The plan before us today completely lacks common sense,” he added.

The decision ends a nearly two-year debate over de Blasio’s bid to overhaul the city’s jail system by significantly lowering its prison population — which historically has been predominately black and Hispanic — while also making living accommodations safer and more humane following decades of complaints of mistreatment at Rikers.

It has faced an eclectic mix of stiff community opposition, including residents concerned the new jails will be too large and ruin their quality of life, and organized civic groups who want Rikers closed – but without building new jails.

The day was marked by sporadic protests from those opposed to the construction of any new penal facilities.

About 50 to 60 “No New Jails” protesters had to be cleared from the balcony of the Council Chambers after they dropped several paper flyers onto those below.

“If you cage our future, [there will be] blood on your hands,” read the flyers, which bore the ominous image of a reddened hand sticking up between cell bars.

De Blasio predicts the city’s jail population — currently about 7,000 inmates — will drop to 3,300 by 2026, when Rikers is expected to close and the new jails open. To meet his goal, he’s banking on state bail reforms that went into effect in April, the expansion of a city-funded supervised release program and other initiatives aimed at driving the prison down.

There were about 11,000 inmates in city lockups in 2014 when the mayor came into office.

Johnson said he is “confident” the jail population would drop but conceded there is no backup plan in place to house extra prisoners should the goals not be met.

The close-Rikers plan garnered key last-minute support from some council members, thanks to a sweetheart deal hammered out earlier this week. The deal included agreeing to pour $391 million in city funding toward citywide criminal justice reforms and community-based investments in neighborhoods getting the new lockups, including new affordable housing and community centers.

The de Blasio administration also agreed to lower the height of the new jails by an average of nine stories — in the process going from 1,150 beds each to just 886, for a combined capacity of 3,544.

Rikers, in comparison, can hold 15,000 inmates.

De Blasio first announced plans to shutter the notorious prison complex in March 2017. It was an about-face from the previous year when he rejected calls by then-Council Speaker Melissa Mark-Viverito and Gov. Andrew Cuomo to close Rikers.

Mark-Viverito received cheers at Thursday’s meeting.

Following the Council’s decision, de Blasio held a congratulatory press conference at City Hall to thank everyone involved in getting the legislation passed.

“Today we made history! The era of mass incarceration is over,” Hizzoner crowed. “It’s over!”

Like Johnson, he also expressed confidence that there will never be a shortage of prison beds once the new jails open — despite not having a contingency plan.

“Look! God forbid if there’s a situation, there’s always some way to come to an alternative,” he said. “But I really don’t see that.”

Officials have yet to offer a concrete timeline for closing the jails spread throughout the 413-acre island.

The Council also backed a separate measure to begin the process of making it so Rikers could never be used to house a jail again after 2026 — by designating the island a public place. Those plans, however, still face a lengthy land-use public review process that would eventually conclude with a full council vote.