Thriller “The Perfect Guy” narrowly beat out horror film “The Visit” for first place at the weekend box office, picking up a leading $26.7 million.

“The Visit,” M. Night Shyamalan’s return to the shock and chills genre that made him famous with “The Sixth Sense,” was close behind with a sterling $25.7 million. Going into the weekend, both films were expected to pull in between $15 million and $17 million.

“The Perfect Guy” has more than doubled its $12 million budget in a single weekend, putting it on a path to profitability. The story of a successful lobbyist (Sanaa Lathan) who rebounds from a breakup by embarking on a new relationship with a Mr. Wrong (Michael Ealy) was backed by Sony’s ScreenGems division. The studio had a similar success on the same weekend last year when “No Good Deed,” a thriller with Idris Elba and Taraji P. Henson, debuted to $24.2 million.

“It’s ideal timing, because there’s not a lot of competition in the marketplace and you can really stand out with a slightly lower [ad] spend,” said Josh Greenstein, president of worldwide marketing and distribution at Sony.

In order to bring in its audience while keeping costs at a minimum, the studio aggressively went after African-American moviegoers. It launched a BET Awards takeover for “The Perfect Guy” and also debuted a customized trailer to appear alongside “Straight Outta Compton” that was wordless save for a sultry rendition of “I Put a Spell On You.”

“We wanted to sell it as a sexy, taut thriller,” said Greenstein. The picture marks the first ScreenGems title he has handled the marketing campaign for since he was brought over to Sony from Paramount Pictures in 2014.

“The Visit” arrives courtesy of producer Jason Blum’s Blumhouse label and cost a slender $5 million to produce, very much in keeping with the economic model of a company behind micro-budget hits like “The Purge” and “Sinister.” Universal distributed the film in 3,069 theaters. Its success represents a comeback for Shyamalan whose career was colder than one of those “Sixth Sense” dead people after “The Last Airbender,” “Lady in the Water” and “After Earth” all flopped.

“M. Night Shyamalan is back,” said Nicholas Carpou, head of domestic distribution at Universal. “This was a great collaboration. There was a lot of goodwill out there for a master storyteller working in this genre.”

“The Perfect Guy” and “The Visit” both tried to appeal to different segments of the movie-going public — the former made its pitch to African-American audiences, while the latter appealed to younger ticket buyers — although there was some demographic overlap in who showed up. “The Perfect Guy’s” opening weekend crowd was 70% female, 41% under the age of 25, 61% African-American, 20% Caucasian and 13% Hispanic. “The Visit” brought in a group that was 48% under the age of 21, 60% female, 39% Caucasian, 39% Hispanic and 10% African-American.

The strong grosses for both films helped push overall ticket sales up more than 15% from the year-ago period when “No Good Deed” and “Dolphin Tale 2” topped charts.

Not every new release was so lucky. Samuel Goldwyn’s “90 Minutes in Heaven” failed to connect with faith-based crowds, earning a disappointing $2.2 million across 878 theaters. It may have been overshadowed by the continued strength of “War Room.” The Sony Pictures and Affirm faith-based family drama was third place at the box office, taking in $7.4 million for the weekend and bringing its domestic haul to $39.2 million. It is now the highest-grossing picture of filmmaking brothers Alex Kendrick and Stephen Kendrick’s career, topping 2011’s “Courageous” and its $34.5 million total.

The top five was rounded out by Broad Green’s “A Walk in the Woods” with $4.7 million, bringing its total to $19.9 million, and Paramount’s “Mission: Impossible – Rogue Nation” with $4.1 million, pushing its domestic gross to $188.2 million.