NEW YORK  — The R-rated spy comedy Kingsman: The Golden Circle has taken over the top spot at the box office with an estimated $39 million debut.

The second installment pushed the Stephen King sensation It into second place in its third week of release. But It still continues to pull in record crowds. With $30 million over the weekend, It is now the highest-grossing horror film of all time, not accounting for inflation, with $266.3 million thus far.

Taron Egerton returns as superspy Eggsy in 'Kingsman: The Golden Circle.'

The unexpectedly strong performance of It may have slightly hurt the opening of the Kingsman sequel.

More: Taron Egerton is a gun-wielding Luke Skywalker in 'The Golden Circle'

Also: The very best and very worst Stephen King movies (including 'It'), ranked

The Lego Movie spinoff The Lego Ninjago Movie, was further off expectations, making its debut in third with $21.2 million. It was the second Lego Movie spinoff of the year, following February's The Lego Batman Movie.

Rounding out the top five: Dylan O'Brien's American Assassin, adapted from the Vince Flynn book, finished fourth with $6.3 million and Reese Witherspoon rom-com Home Again fell to fifth with $3.3 million.

Final numbers are expected Monday.

Contributing: Kim Willis