The holiday-season cheer of the trendy Upper West Side was shattered yesterday when a career criminal slaughtered three members of a family in their apartment — then plunged to his death after tripping over his baggy pants.

The bloodshed began when the killer barged into the family’s third floor apartment and opened fire at around 1:45 p.m., near a string of upscale shops on Amsterdam Avenue near West 83rd Street.

Gunman Hector Quinones blew away 24-year-old Carlos Rodriguez Jr., and his father Carlos Rodriguez Sr., 52, and then repeatedly stabbed grandfather Fernando Gonzalez, 87, to death before the elder Rodriguez’s wife and adult daughter walked unwittingly into the carnage in the apartment they all shared.

As soon as Gisela Rodriguez, 49, and her daughter, Leyanis, 28, walked inside, Quinones, 44, opened fire again at the mother, grazing the back of her head, cops said.

/upost/upload_photo?gallery_id=uws_massacre

He then went after Gisela’s daughter, who scrambled for safety and ran to a nearby bedroom. The killer was inches away from grabbing her but tripped over his low-slung pants, sources said.

The horrified woman managed to slam and lock the door just in time, only to find the bloodied bodies of her brother and dad inside.

A relentless Quinones kicked the door in and lunged for Leyanis, but she was able to make it to a fire escape, screaming for help to construction workers on the roof of the building next door.

“She just ran in and told the contracting guys there was a shooting, there’s somebody who got shot,” said the building manager, who declined to identify herself. “She was hysterical, she couldn’t talk.”

Meanwhile, her wounded mom scrambled to safety out the front door.

“They rushed her into the ambulance,” said Dmitri Vezyrakis, 42, the owner of Caesar’s Palace Pizza. “I saw blood on the covers of the sheets.”

She was later taken to Roosevelt Hospital in stable condition.

Fleeing empty-handed, Quinones ditched his gun, a .380-caliber semiautomatic pistol loaded with hollow-point bullets, and made a dash down a rear fire escape.

But again, his low-slung pants fell to his ankles, tripping him and sending him falling three stories to his death, authorities said.

Investigators found a “significant amount” of heroin and a smaller amount of cocaine inside the apartment, as well as a cash-stuffed lockbox that cops confiscated, Commissioner Ray Kelly said.

The suspect, who has 14 prior arrests for offenses that include manslaughter, assault, drugs and robbery, knew Rodriguez Sr. from when they were in prison together, sources said.

He’d been released from prison in August after serving seven years on the manslaughter charge.

Rodriguez Sr. had eight arrests — mostly for dealing drugs — and had met Quinones when they served time together in the 1990s, sources said.

“This was a drug robbery gone awry,” one source said.

The elder Rodriguez was arrested last month for carrying a knife, and Kelly said there had been a report that the younger Rodriguez had been dealing drugs on the street, although he was never arrested.

Investigators found the Rodriguezes –who both worked as construction workers — dead in the bedroom. Gonzalez was stabbed to death in the bathroom.

Quinones, wearing leather gloves on top of rubber ones, ransacked the bedroom after killing the three men, police said.

A bloody knife — with an 8-inch blade and a 4-inch handle — was found in the kitchen.

After getting out of prison, Quinones was friendly with the elder Rodriguez, who was known around the neighborhoods as Fat Boy and Pecal, said neighbor Mike Garcia, 20.

“It’s a tragedy,” Garcia said. “Something like this happened 10 years ago around here, but not now.”

Gonzalez was nicknamed Cubano and neighbors said he loved walking his 10-year-old granddaughter and 7-year-old grandson to school at PS 78 every morning.

“He never bothered anyone,” said neighbor Dileen Costas. “It was like clockwork — a little after 8, he’d walk his grandkids to school. He loved those kids.”

Longtime family friend Joey Columbus, 24, was devastated at the loss of Carlos Jr.

“He was a family man,” Columbus told The Post, after walking out of the 20th Precinct station house. “He loved his nieces and nephews.”