Perhaps what happened to the Rivington House property on the Lower East Side involved only a disturbing level of incompetence. But it could just as easily be a story of malfeasance and corruption.

It’s the first whiff of real scandal in Mayor Bill de Blasio’s term. It threatens to undermine efforts on affordable housing and health care, two key issues for the city, and for him.

There is much we don’t know, but somehow, a relatively small nursing home for AIDS patients in a rapidly gentrifying area was quietly transformed into a planned $116 million luxury condominium project.

The mayor says a private company took advantage of the city to make a small fortune — without his knowledge. The company, Allure Group, says it did nothing wrong and simply followed city procedures.

Meanwhile, the local community board tried to tell the mayor about potential trouble in January, but either was never heard or ignored. Anthony Shorris, the first deputy mayor, knew in February but didn’t tell de Blasio because, city officials said, he was still gathering the facts. Then there are campaign contributions to the mayor from an Allure official and donations to de Blasio causes from a lobbyist who worked for the companies involved.

It’s a complicated, smelly mix.

A $72 million profit

Rivington House was long a nursing home for patients with HIV and AIDS. Its owner, Village Care, sold the building to Allure Group in early 2015 for $28 million.

In May, according to reports, Allure signed a contract to sell the building to Slate Property Group and its partners — for $116 million. Their plan: to build condominiums. That deal had one contingency: that the city would lift a restriction on the building’s deed which previously allowed only nonprofit residential health care use. In exchange for the restriction’s removal, Allure paid the city’s Department of Citywide Administrative Services $16.15 million. All told, Allure still cleared a $72 million profit.

City officials thought the change would allow Allure to maintain the building as a for-profit health care facility. Allure, the city said, wrote an email to officials in 2014 about those plans. But the city didn’t seem to get any definitive agreements — no further restrictions on the building’s use, no contracts, no written policies and no promises. Allure reportedly closed the Slate deal in February, weeks after the community board passed a nonbinding resolution to keep Rivington a health care facility. It was a warning unheard.

Start an independent probe to clear the air

The story has a messy political side. Allure official Joel Landau donated nearly $5,000 to de Blasio’s 2013 campaign — a donation the mayor says he will return. Meanwhile, city lobbyist James Capalino, who has contributed to de Blasio causes, has done work for Village Care and for Slate. Capalino said his work had nothing to do with the property.

Questions abound about what happened, how the community wasn’t heard, who knew what and when, and why city policies apparently were so lax. City Hall says an internal investigations team will get to the bottom of it. Comptroller Scott Stringer has launched an audit, but he has his own political goals. Let’s cut to the chase. Manhattan District Attorney Cyrus Vance or U.S. Attorney Preet Bharara should open a criminal probe. De Blasio should welcome an independent investigation to get this cloud removed.