Chants of "U-S-A! U-S-A!" echoed through the arena as Avery Wilson sang The Star-Spangled Banner, but they they gave way to boos moments later as Trump was displayed on the jumbo screens giving a military salute.
The jeers ended when the US flag followed him on the screens, and fans cheered when New York Knicks players were shown.
Trump watched game three from Knicks owner James Dolan's suite, along with granddaughter Kai, personal adviser Boris Epshteyn and Cabinet secretaries Lee Zeldin, Sean Duffy and Doug Burgum.
He sat next to Dolan for the first quarter and spent part of the second talking to NBA Commissioner Adam Silver and Republican gubernatorial hopeful Bruce Blakeman.
According to the NBA, Trump is the first sitting US president to attend an NBA Finals game.
"He's a genuine Knicks fan," NBA Commissioner Adam Silver said of Trump before the game at Madison Square Garden. Before his time in politics, Trump frequently attended Knicks games and often sat courtside.
Trump's Marine One helicopter flew from his home in New Jersey and landed near Wall Street before his motorcade made its way up through Manhattan and to the arena roughly an hour before tipoff.
He encountered a handful of people making rude gestures, and outside the area, one group held signs saying "Trump must go."
During the afternoon before Trump's arrival, the New York Police Department and the US Secret Service set up a large perimeter surrounding Madison Square Garden.
Fans lined up to get inside the arena more than four hours before tipoff, in a scene more closely resembling New Year's Eve in Times Square than the usual lead-up to a basketball game.
They were required to provide a ticket or pass to get past various checkpoints.Â
Secret Service personnel and police were positioned at every corner and in large numbers. Daily commuters, tourists visiting Manhattan and fans were all confounded at various times as they tried to manoeuvre the security.
Since returning to the White House last year, Trump has attended the Super Bowl and a US Open tennis match.
with DPA