James Gandolfini, the Hollywood heavyweight who won multiple Emmy Awards for his role as mob boss Tony Soprano in the smash HBO series “The Sopranos,” died of a heart attack Wednesday.

HBO confirmed his death. He was 51.

Gandolfini was stricken in Rome and was due to appear at the Taormina Film Festival in Sicily this weekend.

“I have lost a brother and a best friend. The world has lost one of the greatest actors of all time,” tweeted Steven Van Zandt, Gandolfini’s friend who played Tony Soprano’s consigliere Silvio Dante in the series.

CELEBS PAY THEIR RESPECTS TO GANDOLFINI

LOU LUMENICK LOOKS BACK ON GANDOLFINI

PHOTO GALLERY: JAMES GANDOLFINI

The Westwood, NJ,-born actor played Soprano in the critically acclaimed series, which ran from 1999 to 2007 and ended with the screen fading to black.

“When I first saw the ending, I said, ‘What the f–k?’ ” Gandolfini told Vanity Fair of the last episode. “I mean, after all I went through, all this death, and then it’s over like that?”

In the interview, he defended the violence on the show, saying the show’s characters paid for the pain they dealt.

“We’d get accused, back then, of glamorizing mobsters, but we were all half-miserable, you know. I don’t think the violence looks appealing at all,” he said.

“Everyone paid for the violence in a lot of ways. … It’s a very violent world and, you know, there’s consequences. I think we showed it, and I think we showed the toll it takes on these people.”

Gandolfini reinvented and invigorated the tough-guy mafioso, playing complex criminals whose violent ways were tempered by their emotional frailties.

Tony Soprano saw a shrink and fought with his wife even as he whacked his enemies.

And the actor himself had his own demons.

Gandolfini battled a drug and cocaine addiction, and went to rehab at one point, it was revealed in 2002.

“He was a genius. Anyone who saw him even in the smallest of his performances knows that. He is one of the greatest actors of this or any time,” said David Chase, the show’s creator.

“A great deal of that genius resided in those sad eyes. I remember telling him many times, ‘You don’t get it. You’re like Mozart.’ There would be silence at the other end of the phone. For Deborah and Michael and Lilliana this is crushing. And it’s bad for the rest of the world.

“He wasn’t easy sometimes. But he was my partner, he was my brother in ways I can’t explain and never will be able to explain.”

His fellow actors on the show remembered him as unpretentious and generous.

“He is my best friend in life,” said Tony Sirico, Tony Soprano’s close friend and fellow wise guy “Paulie Walnuts” on the hit series. “He helped me more than anyone else with my career. He is a great person and a family guy.”

And Vince Curatola, who played John “Johnny Sack” Sacramoni, said, “I used to call him the ‘Fearless Leader.”

“I was just coming off the ferry from Manhattan when I heard [about Gandolfini] and I said, ‘I hope this is a rumor.’

“We were together at Mohegan Sun in March and had a great time. I don’t know what happened. [Gov.] Chris Christie just called me and said, ‘When they bring him home, we’ll do whatever his family needs,’ because he’s a Jersey boy.”

Gandolfini was born on Sept. 18, 1961, and grew in Park Ridge — his mother, Santa, was a lunchlady and his dad, an Italian immigrant, held blue collar jobs.

He attended Rutgers University. and had his first Broadway role in 1992’s “A Streetcar Named Desire.”

His breakout big-screen role was as Virgil, a cold-blooded hit man in the Quentin Tarentino-penned “True Romance.”

“Now the first time you kill somebody, that’s the hardest,” his character told his target during a chilling monologue. “ Now … s—… now I do it just to watch their f—in’ expression change.”

He also had roles movies like “Crimson Tide,” “Get Shorty,” and “The Mexican,” where he played a gay hit man.

Gandolfini recently played Leon Panetta in “Zero Dark Thirty,” which is based on the raid to take down Osama bin Laden.

“I sent a note to Leon saying, ‘I’m very sorry about everything. The wig, everything. You’re kind of like my father. You’ll find something to be angry about,’” he said earlier this year.

Gandolfini had a lot to look forward to.

He recently married his second wife, Deborah Lin, with whom he had a baby girl last October.

And he was set to star in a seven-episode series called “Criminal Justice” on HBO, in which he would play low-rent lawyer Jack Stone.

He signed a deal with CBS earlier this month to adapt a French sitcom, “Taxi-22” — about a politically incorrect New York cabbie — for the network.

Gandolfini was expected to executive-produce the show through his company, Attaboy Production.

His Tribeca neighborhood was shocked by the news — and flowers were lain outside his building.

“He’s the nicest guy in the building. If you ever needed anything he’d always help you out,” his Greenwich Street doorman said.

“I can’t believe this. He just had a baby girl a little while ago. He seemed fine.”

A manager at Locanda Verde, a favorite haunt of Gandolfini, which is owned by Robert DeNiro, said he was “just a true gentleman, humble and noble man. He was just a good guy — a young guy. I have chills right now talking about it.”

In a statement, HBO called him “a gentle and loving person who treated everyone no matter their title or position with equal respect.

“He touched so many of us over the years with his humor, his warmth and his humility. He will be deeply missed by all of us.”

Additional reporting by Erin Calabrese