ORLANDO, Fla. — Rory McIlroy was in search of some mojo when he played the Arnold Palmer Invitational two years ago.

McIlroy, 30, hadn’t won a tournament since 2016, then he won at Bay Hill in 2018 and that appeared to change everything. McIlroy went on to win three times last season, has won once this year and enters Thursday’s opening round of the Arnold Palmer Invitational ranked No. 1 in the world.

He’ll play alongside 2019 API winner Francesco Molinari and Justin Rose for the first two rounds, beginning with Thursday’s 7:54 a.m. tee time.

“This was the start of a two-year journey to get back to this point,’’ McIlroy said after playing his pro-am round Wednesday. “I came here two years ago off the back of a missed cut in Tampa and sort of a little lost with my game — especially a little lost with my putting. And [I] spent an afternoon with Brad Faxon at the Bear’s Club and then came up here and, obviously, something stuck with me from that afternoon and was able to win and that was my first win in 500-whatever days.

“So, I feel like this place is a lot of special memories to me. It was definitely the catalyst to sort of do what I’ve done over the past two years and ascend back to the top of the world rankings. So, it’s good to be back.’’

Among those to watch challenging McIlroy is Brooks Koepka, whose results have been poor since he had a minor knee procedure. Koepka this season has two missed cuts (including last week’s Honda Classic). This comes after Koepka dominated the golf world with six wins, including four majors from 2017-19.

Koepka is playing alongside Adam Scott and Jason Day for the first two rounds. It’s possible for him to overtake McIlroy for the No. 1 ranking this week with a win and a poor week for McIlroy.

The second part of that equation, however, doesn’t seem likely, considering how consistently McIlroy has played the past two years. He’s played in five tournaments in 2020 and has not finished worse than fifth, winning the HSBC-Champions.

“Mentally over these last few years I’ve definitely gotten better and [with] more stability in my life [he’s married]. … I’m just a lot more comfortable with where everything is,’’ McIlroy said. “I have done things in the game previous to two years ago that were maybe higher than what I’ve done the past couple of years, but from a mental perspective the consistency and showing up every week, even when I don’t have my best stuff I’m able to still get in the mix and have a shot at winning tournaments.’’