The single sold 82,000 combined copies last week, around half of which came from the song's 4.1 million streams.
The sales put I Took a Pill in Ibiza about 11,000 copies ahead of its closest rival - 7 Years by Lukas Graham.
It's the second UK hit for 28-year-old Posner - his debut single Cooler Than Me reached number five in 2010.
Posner said: "To be number one in the UK is quite an honour.
"It's very flattering to know this many people are listening to my music and enjoying it enough to give me money for it."
Fifth Harmony, the girl group formed on X Factor USA, are at number three this week with Work From Home - a new peak for the song.
Completing the top five is Zara Larsson's Lush Life at number four, and Say You Do by Sigala feat. Imani and DJ Fresh, which has climbed 46 places.
On the album chart, Adele's third album 25 scores its 12th non-consecutive week at number one.
Manchester band James's 14th studio album Girl At The End Of The World takes the number two slot, pushing Justin Bieber's Purpose down to third place.
Jess Glynne also slips a place to number four, and Iggy Pop enters at number five with his latest album Post Pop Depression.
Other new entries on this week's album chart include British electronic group Underworld, who are new at number 10 with their first album in six years, Barbara Barbara We Face A Shining Future.
Primal Scream land at number 12 with their 11th record Chaosmosis, while former No Doubt singer Gwen Stefani enters at number 14 with her third solo album, This is What the Truth Feels Like.
The Batman v Superman: Dawn of Justice soundtrack, composed by Hans Zimmer & Junkie XL, debuts at number 31, as the film goes on release this weekend.
Room 94's Lost Youth enters at number 33, while 30 Goes Around The Sun by The Wonder Stuff reaches number 38.
Meanwhile, the latest Now That's What I Call Music! compilation, Now 93, has become the fastest selling album of 2016 so far, shifting 247,000 copies this week.
Mike Posner has scored a second week at number one with his dance track I Took a Pill in Ibiza.