An off-duty corrections officer fatally shot a gunman who tried to rob his motorcycle in Queens, cops said.

The Queensboro corrections officer was standing outside 82-10 Rockaway Boulevard in Woodhaven with four other bikers when they spotted a man with a gun walking toward them around 10:30, Saturday, cops said.

“Give me your keys,” said the man, pointing a .380 caliber handgun, cops said.

The corrections officer then fired a shot striking the robber in the head, cops said.

The unidentified man was taken to Jamaica Hospital where he was pronounced dead, cops said.

The corrections officer is not expected to be charged with a crime.