There aren’t many women who can steal a pop princess’ thunder without even trying. But, as Britney Spears discovered at her New Year’s Eve soiree in Las Vegas, extending an invitation to Sofía Vergara will render any hostess invisible.

“Sofía walked into the backstage area and the room literally fell silent,” a guest at the Planet Hollywood event tells The Post. “The guys were all gawking, and the women’s eyes were on stalks. Nobody was interested in watching Britney.”

The curvaceous 42-year-old is certainly used to turning heads — and her omnipresence makes her hard to ignore.

Not only is the “Modern Family” star one of TV’s highest-paid women, she also presides over a $37-million endorsement empire, hawking everything from diet soda to dandruff shampoo.

With a chiseled fiancé — “True Blood” and “Magic Mike” star Joe Manganiello — and the drama “Wild Card” opening in theaters Friday, the Latina’s life appears charmed. But her rise to the top has been fraught with tragedy and heartache.

One of six children born to a housewife and a cattle farmer in Barranquilla, Colombia, Vergara was scouted for her first TV commercial at 17.

The Pepsi ad, which featured the teen beauty in a bikini, was an immediate hit throughout Latin America.

But, for a while at least, Vergara eschewed red carpets in favor of root canals. It was while studying dentistry that she married her childhood sweetheart, José “Joe” Gonzalez; a year later, 20-year-old Vergara gave birth to a son, Manolo.

The couple divorced in 1993, and Vergara dropped out of dental school and moved to Bogotá. She was soon in demand as a model, landing a starring role in the Mexican telenovela “Acapulco, cuerpo y alma.”

Soon, other networks took notice and Vergara was “ecstatic” when, in 1994, Univision asked her to host a travel show based in Miami.

“She saw it as a chance to give her son a better life,” an insider says, adding that the star had become fearful of gang-related violence in her homeland. “She said yes immediately.”

In 1998, her older brother Rafael, 27, was murdered in their hometown. “We come from a successful family, and he knew he was a target for kidnapping,” the actress has said. “He always had bodyguards. Then one day he went out alone and was shot dead [in a kidnapping attempt gone wrong]. I was devastated.”

Just two years after Rafael’s death, Vergara was diagnosed with thyroid cancer. “I felt totally healthy, and suddenly they tell me I have cancer?” Vergara told Parade magazine. “I was scared.” But the cancer was caught at an early stage and the treatment — surgical thyroid removal, and a course of radioactive iodine treatment — proved successful.

Still, her love life was in turmoil.

In the mid-1990s, the actress had become involved with Chris Paciello, the darling of Miami’s South Beach nightclub scene, who originally hails from Staten Island. Paciello’s reputation as a mobster preceded him — he was a member of a gang that operated under the auspices of the Bonanno crime family, with a rap sheet of alleged burglaries and bank heists so lengthy he earned the

nickname “The Binger.”

“They seemed very much in love,” an associate tells The Post.

The lifestyle was certainly seductive. Paciello’s nightclub-business partner, Ingrid Casares, was friends with Madonna, and the Material Girl was now a regular on the Miami scene, along with Casares pals Jennifer Lopez, model Niki Taylor and MTV star Daisy Fuentes. His fearsome reputation coupled with Casares’ connections meant that “Paciello had a lot of power and influence,” the source says.

In 2000, the same year Vergara received her cancer diagnosis, Paciello was charged with the felony murder of a Staten Island housewife in a botched 1996 robbery. Vergara offered her Miami home as collateral toward her lover’s $15 million bail, and watched, impassively, as he blew her kisses in the courtroom.

She has never forgotten who she is. She’s very loyal and has the same manager who’s been with her since the start. - Photographer Manny Hernandez, who has known Vergara for more than 20 years

Paciello pleaded guilty to murder and ratted out mob bosses to shorten his sentence. He eventually served six years in jail, and the couple went their separate ways, but Vergara’s predilection for “bad boys” hadn’t waned.

She reportedly had a fling with former Colombian drug lord Andrés López López, who was released from a 20-month jail stint in 2004. In an interview, he called the actress “a marvelous woman who I love dearly.”

Following a guest role on ABC’s “My Wife and Kids,” Vergara signed a long-term contract with the network, and she and her son moved to Los Angeles in 2005.

Shortly after, she was introduced to Tom Cruise at a party.

According to the the actor’s unofficial biographer Andrew Morton, Cruise “laid on the charm with a trowel.” Morton claims that Vergara’s son was invited to play with Cruise’s kids and that, following trips to the Scientology Celebrity Center, “. . . there was no doubt [Tom] was auditioning [Vergara] for the part of his wife.”

But the Catholic actress allegedly had no intention of becoming the next Mrs. Cruise.

“She sincerely believed that she would be struck down by God and burn in hell if she joined [Scientology],” Morton claims. (Cruise went on to marry Katie Holmes a year after his ill-fated dalliance with Vergara.)

The relationship may have foundered, but the actress’ association with an A-lister had piqued Hollywood’s interest -— and the tabloid moniker “Sofía Viagra” was born.

Next up were supporting parts in the Tyler Perry movies “Meet the Browns” and “Madea Goes to Jail.” ABC cast Vergara in several shows — 2007’s “Dirty Sexy Money” was a moderate success — but it was the 2009 debut of “Modern Family” that changed her life.

The part of trophy wife Gloria Delgado-Pritchett was reportedly written for Vergara, and — with her low-cut necklines and Colombian accent intact — she became the show’s standout. Her weighty paychecks (Vergara now commands $325,000 an episode) allowed her to indulge in private jets and Hermès handbags, but family still came first.

To mark her 40th birthday in 2012, Vergara flew 107 loved ones to Mexico for a weeklong celebration and “picked up the tab for everyone,” sources say. She purchased 21 tickets for the 2013 Emmy Awards so that her family could have a taste of her showbiz life. (Nominated for Outstanding Supporting Actress in a Comedy Series in 2010, 2011, 2012 and 2013, she has never won.)

“She has never forgotten who she is,” photographer Manny Hernandez, who has known the star for more than 20 years, tells The Post. “She’s very loyal and has the same manager who’s been with her since the start.”

Vergara is particularly close to the son she raised as a single mother.

“She had her career and she still managed to raise me at the same time,” Manolo, now 22, has said. “She’s a Latin mother, which means she’s very loud, and sometimes very overprotective.”

Sadly, Vergara’s dedication to family could not save them from tragedy.

Having brought her younger brother Julio to Miami after their older sibling’s death, Vergara watched helplessly as he battled drug and alcohol addictions that resulted in 30 arrests over a decade. In 2011, Julio was deported back to Colombia.

“To see somebody dying over 10 years, little by little, that’s the worst punishment. Now he’s like another person,” Vergara told Parade. “With so many bad things happening, it creates a tough skin . . . Even when horrible things happen to me, I go on.”

That sense of stoicism was further tested during her volatile relationship with Onion Crunch founder Nick Loeb, 39. The couple met at a Golden Globes party in 2010 and were on and off for four years.

“They would fight all the time . . . It was very uncomfortable to be around them sometimes,” a source confides. “She’s feisty, he’s dorky — they were like oil and water.”

Vergara’s continuing friendship with Paciello, now out of prison, didn’t help matters. At a New Year’s Eve party at Paciello’s Miami nightclub Story in 2012, a brawl ensued between Loeb and security.

Vergara later cut all ties to her ex, and branded Paciello a “thug” on Twitter, but her relationship with Loeb was beyond repair.

“The arguments just accelerated after that,” the insider adds. “He felt humiliated, and she felt that he was trying to control her.”

The Post’s Richard Johnson reported that Vergara was turned off by Loeb’s constant hucksterism of his Onion Crunch brand, including trying to sneak the condiment into a White House dinner.

The couple finally split last May, two months before Vergara went public with her latest paramour, actor Joe Manganiello.

The photogenic couple got engaged on Christmas Eve during a romantic Hawaiian vacation, and Vergara “seems blissfully content,” a friend tells The Post.

With rumors of a summer wedding swirling, baby news may soon follow.

Having frozen her eggs back in 2013, Vergara has been candid about her willingness to use a surrogate if she cannot conceive naturally.

“She’s found her dream guy. After all the ups and downs she’s had, she truly deserves this,” the friend concludes.

“It’s finally the best time of her life.”