A Dudley man was caught carrying a gun inside a Boston hospital this week and told officers he was holding it for a friend who went in to undergo a medical procedure.

Jason Kent, 31, was arrested after being charged with illegal gun possession Monday.

Kent was caught at Brigham and Women’s Hospital after someone alerted police he was carrying the gun.