An out-of-towner who stashed his loaded handgun under the mattress in his Brooklyn hotel room, and then called the front desk after checking out to say he forgot it, will be spending at least one more night in the Big Apple — as a guest of the state.

Torrie Flock, 23, of Charlotte, N.C., rang the front desk at the Harbor Motor Inn on Shore Parkway in Gravesend Monday afternoon to say he’d left a .45-caliber Smith & Wesson under the mattress in Room 218, officials said.

When he returned to retrieve the firearm around 1:30 p.m., cops were waiting and arrested him.

A maid had previously gone in to grab up the gun, wrapped it in a towel, and handed it over to police.

The firearm had seven rounds in it, according to prosecutors, who said Flock told officers , “I didn’t know it was such a big deal.”

Defense attorney Dara Hebert said her client had just been in town doing “touristy stuff,” like visiting the Statue of Liberty and Times Square. North Carolina is an open-gun state, Hebert added, saying her client did not need a license to purchase the weapon there.

Flock was arraigned on criminal possession of a weapon charges Tuesday, and held on $7,500 bail.

His gal pal and her father, who were in court with him, declined to comment.