A madman set a deadly blaze at a SoHo apartment building last night after attacking his wife in a domestic dispute — and then fought with a cop and a firefighter trying to save lives in the inferno, police sources said.

Wei Chu Wu, 45, allegedly told a roommate, “We’re all gonna die,” after setting ablaze the kitchen of his apartment on the second floor of 41 Spring St., sources said.

The fire, which expanded to five alarms, took 2 1/2 hours to bring under control, killed one unidentified person, whose badly charred body was found on a third-floor fire escape, cops said.

The body was so badly burned that a gender ID wasn’t immediately possible.

More than 200 firefighters battled Thursday’s blaze.

“The fire encompassed all of the floors,” said FDNY Chief of Operations James Esposito. “The building is essentially destroyed. It was an extremely intense operation.”

More than 200 firefighters battled the blaze, which broke out at about 6:40 p.m. Seven were injured.

The domestic dispute that sparked the fatal inferno began when Wu argued with his wife, Yan He Zheng, the mom of his 13-year-old son. The argument grew heated and he cut the 41-year-old woman on the hand, sources said.

Zheng and the boy then fled the building. A short time later a roommate confronted Wu, who issued his chilling prediction.

The roommate then saw the kitchen was ablaze and ran, with Wu following.

After exiting the building, Wu brawled with a cop and a tourist and even a firefighter from California, as would-be rescuers tried to enter.

“We came out of the restaurant and saw two men arguing. We saw flames in the window,” said Noemi Gutierrez, whose LA firefighter husband, Vincent, scuffled with Wu. She and her husband were dining at nearby Lombardi’s when flames erupted.

“My husband went into the building and came out saying the whole second floor was engulfed in flames,” she said.

The 33-year-old cop, Paul Rao, a nine-year veteran officer assigned to the Fifth Precinct, suffered a hand injury and was treated at New York Hospital, police sources said.

Wu was arrested for disorderly conduct and assaulting an officer, police sources said. He was led into the Fifth Precinct in handcuffs late last night, sporting a black eye and appearing dazed.

“I saw the guy with a bloody shirt, a black eye and no shoes. The cops were leading him away in handcuffs. I figured he started the fire,” said neighbor William Bray. “My son plays with [Wu’s] son in the park. They seem like a normal family.”

Residents of the building were devastated.

“The Fire Department just told me I no longer have an apartment. I lived on the fourth floor and everything I own is gone,” said a resident.

Samuel Perez, general manager of the Pinkberry yogurt shop on the ground floor of the building, said the business is imperiled.

“There’s smoke and water damage,” he said. “We’re probably going to have to replace most of the things in the store.”