DORAL, Fla. — An armed man ranting against President Trump opened fire on police officers early Friday at the Trump National Doral Miami Golf Club in South Florida before he was wounded and apprehended, the authorities said.

Although the police did not immediately describe a motive for the attack at the resort, they said the man had tried to ambush officers and had yelled “anti-Trump” rhetoric.

“We don’t know what his intentions were — long-term intentions — but we know what he was trying to do at the time, and it appears that he was trying to engage our police officers, some kind of ambush-type attack, trying to lure our police officers,” said Juan J. Perez, the director of the Miami-Dade Police Department.

Mr. Perez said that the suspect, identified as Jonathan Oddi, 42, “did succeed, and he did lose” the gunfight at the hotel, which the Trump Organization owns. The hotel, located in Doral, Fla., is west of Miami and about 70 miles from the Mar-a-Lago retreat that Mr. Trump has called the “Winter White House.”