TMZ has learned ... the man who allegedly attempted to break into Paris Hilton's L.A. home this week was thwarted by Hilton's boyfriend ... who pulled a gun on the suspect before the dude could get inside.
Law enforcement sources confirm ... Hilton's BF -- Vegas nightclub kingpin Cy Waits -- told police that he and Paris heard loud banging noises coming from downstairs around 6:30 AM Tuesday ... so he grabbed his gun and went to check out the situation.
We're told Cy claims he spotted Nathan Parada peering through a window and carrying two knives -- a large kitchen knife and a buck hunting knife.
Cy immediately went outside -- with his weapon drawn -- and ordered Parada to drop the knives and lay on his stomach. We're told Cy kept his gun pointed at Parada until cops arrived.
Law enforcement sources also tell us Parada told cops that he had purchased a Star Map on Hollywood Blvd. hours before the incident ... because he wanted to find out where Paris lived.
We're told Parada -- who was booked for felony burglary -- is currently in custody on a 5150 psychiatric hold.
Sources close to Paris tell us ... ever since the incident, Hilton's security team has installed several new cameras around the home ... as well as infrared technology designed to spot intruders. Paris has also hired two new bodyguards to protect her around the clock.
According to our sources, Paris has told friends, "Thank God Cy was there, he saved my life."