Rory McIlroy responded on Friday to criticism of his decision to play a round of golf with President Trump this weekend, declaring in a post on his Twitter account that his choice “wasn’t an endorsement nor a political statement of any kind.”

McIlroy, ranked No. 3 in the world, said he had been called a “fascist” and a “bigot” for accepting an invitation to play 18 holes on Sunday with the president at the Trump International Golf Club in Florida.

“Whether you respect the person who holds that position or not, you respect the office that he holds,” McIlroy, who is from Northern Ireland, wrote in the post. He added: “Golf was our common ground, nothing else. I’ve travelled all over the world and have been fortunate enough to befriend people from many different countries, beliefs and cultures.”

McIlroy, 27, was the latest athlete to be caught in the intersection of sports and politics under the polarizing new administration. Several members of the New England Patriots have said they plan to skip the team’s visit to the White House, and Stephen Curry of the N.B.A. publicly took issue with pro-Trump comments by the chief executive of Under Armour, Curry’s primary sponsor.

But McIlroy, who is recovering from a rib injury, is far from the only golfer to have joined the president on the course. Ernie Els, a South African, also received criticism on social media this month when he played with President Trump and Japan’s prime minister, Shinzo Abe, at Trump National Golf Club in Jupiter, Fla. Last week, nearly 90 percent of golfers who were anonymously polled at the Genesis Open said they would play golf with President Trump if asked.

“I felt it was a duty to play with the president if you get the call,” Els said. “If it was Barack Obama, I would have played. If it was Hillary Clinton, I would have played.”

McIlroy has tried to distance himself from contentious political issues in the past. He cited concerns about the Zika virus as his reason for skipping the 2016 Olympics in Rio, but he later revealed that he resented the Games for making him choose where his loyalties lay between representing Britain and the Republic of Ireland; it “wasn’t worth the hassle,” he said.

But a hassle has again found McIlory, despite his stated view that a round of golf with the president is “quite simply, a round of golf.”