Caroline Wozniacki claims she and her family were threatened and abused by spectators during her second-round defeat at the Miami Open.

The Australian Open champion suffered a surprise 0-6, 6-4, 6-4 loss to the unseeded Puerto Rican Mónica Puig on Friday. Afterwards the 27-year-old Dane revealed her parents were subjected to death threats and young members of her family were sworn at.

The world No 2 wrote on Twitter: “During the match last night people in the crowd threatened my family, wished death upon my mom and dad, called me names that I can’t repeat here and told my fiance’s niece and nephew (who are 10 years old) to sit down and shut the f*** up. Meanwhile security and staff did nothing to prevent this and even accepted this to take place.

“While I always encourage fans to cheer for their favourite player, and I thrive on a challenging atmosphere, when certain lines are crossed it makes tennis miserable for both competitors.”

Wozniacki called on the Miami Open organisers to take action to try to prevent a repeat. She added: “I hope the Miami Open chooses to take this seriously because it’s a horrible example to set for the next generation of tennis players and fans.”

On court, both world No 1s suffered shock defeats. Agnieszka Radwanska came from a set behind to stun Simona Halep, winning 3-6, 6-2, 6-3. Then Roger Federer was beaten 3-6, 6-3, 7-6 (4) by Thanasi Kokkinakis of Australia, ranked 175th in the world.

Kyle Edmund suffered a surprise defeat in the second round to the American Frances Tiafoe. With the game tied at one set apiece, Edmund broke in the fifth game of the decider but was broken back as he served for the match. Tiafoe, ranked 63, then powered ahead in the tie-break and, although Edmund saved five match points, the British No 1 eventually bowed out 7-6 (4), 4-6, 7-6 (5).