The Saudi military man who shot up a Pensacola, Fla., naval base, killing three young Americans, visited New York just days before the attack — touring landmarks including the 9/11 Memorial & Museum, according to law enforcement sources.

Mohammed Saeed Alshamrani, 21, arrived in the Big Apple on Nov. 28 — Thanksgiving Day — taking in sights including the Rockefeller Center Christmas tree with three to five other men, all Saudi nationals training at other US military facilities around the country, sources said.

On either Nov. 29 or 30, sources said, that jaunt took Alshamrani and one other man to the 9/11 Memorial & Museum, commemorating the heinous terror attack carried out by 19 fiends — 15 of them Saudis.

Investigators traced the pair to the solemn Lower Manhattan spot because one of them used a traceable payment method to make a purchase in the gift shop, according to sources.

It wasn’t immediately clear what that purchase was, or whether it was made by Alshamrani or his companion.

The trip, which saw the men stay at two hotels including the Hotel Edison Times Square, wrapped up on Dec. 1, according to sources.

Five days later, Alshamrani opened fire with a handgun at Naval Air Station Pensacola, where the second lieutenant in the Saudi air force was receiving aviation training.

The attack left three US Navy students dead and eight others wounded before Alshamrani was gunned down by sheriff’s deputies.

The FBI has said it is investigating with the “presumption” that the strike was terrorism, but the probe remains active.

At least some of the Saudis who accompanied Alshamrani in New York are in custody in Florida, sources said.