The City Planning Commission on Tuesday green-lighted Mayor Bill de Blasio’s controversial plan to shutter the scandal-scarred Rikers Island prison complex and replace it with four new, smaller borough-based jails — but not before getting an earful from opponents who virtually took over the special meeting.

Commissioners voted 9-3 in favor of building new jails in Manhattan, Brooklyn, Queens and the Bronx but were drowned out trying to explain their votes by a crowd of nearly 100 opponents. Many of them accused the commission of being filled with “white supremacists” and not caring about minorities.

“No new jails! Close Rikers now!” the crowd repeatedly chanted.

Two cops were stationed at the meeting but they sat in the back, silent. Commissioners never addressed the crowd screaming and cursing at them during the meeting — a rarity for any public meeting.

The plan now goes to the City Council for final approval.

De Blasio last year announced he intends to close Rikers by 2027 and move its detainees closer to courts and their families in every borough except Staten ­Island. It is part of a larger plan aimed at bringing the city’s jail population — currently 7,400 — to under 5,000 by 2027. In 2017, Rikers averaged about 9,400 detainees daily.

The four jails are slated to be built on the site of a nine-story government building at 80 Centre St. in Lower Manhattan, the NYPD’s Bronx tow pound in Mott Haven, the currently shuttered Queens Detention Center in Kew Gardens, and the Brooklyn House of Detention in Cobble Hill.

The seven commission appointees who serve at the pleasure of de Blasio voted in favor of the plan, but three of the five appointees tapped by the borough presidents opted to reject it.

The “no” votes were cast by Alfred Cerullo III of Staten Island, Orlando Marin of the Bronx and Raj Rampershad of Queens. Michelle de la Cruz, an appointee selected by the public advocate, did not attend the meeting.

The proposal has long been met with plenty of opposition, including activists in both Lower Manhattan and downtown Brooklyn who contend the new jails would be too big for the targeted neighborhoods to handle and would bring unwanted additional gridlock, parking problems and air pollution.

The Brooklyn plan includes gutting the existing detention center and replacing it with a larger one that could soar as high as 40 stories. In Manhattan, the planned jail could rise up to 45 stories high.

Meanwhile, South Bronx civic groups have accused de Blasio of being a hypocrite for trying to impose a jail on a minority neighborhood that doesn’t want it.

The new jails also have to be approved by the City Council as part of the city’s Uniform Land Use Review Procedure, which allows community members to weigh in.

The council’s Subcomittee on Landmarks, Public Siting and Maritime Uses will hold a public hearing on the borough-based jail system plan at 10 a.m. Thursday at City Hall.