In 2122, a lone XenomorphDrone got aboard the USCSS Nostromo and began killing the crew one-by-one until only Ellen Ripley was left. Ripley activated the ship's self destruct system and fled to the Narcissus with the ship's cat Jones and launched the shuttle as the Nostromo was destroyed. However, unbeknown to Ripley, the Alien was already aboard the shuttle and when Ripley discovered it hiding in the wall, she fled to the space suit locker where she donned an MK 50 Compression Suit and armed herself with the harpoon gun. Ripley then sat down at a control console and started the process to open the hatch and flush the creature out; unfortunately, the process gave off steam and the creature became agitated. The Alien then approached Ripley and when the creature was in striking distance of her she opened the hatch to the vacuum of space. The Alien, however, managed to grab the airlock door as it was being sucked out and Ripley shot the creature with harpoon gun getting the harpoon lodged in the Alien's abdomen. The door then closed on the harpoon's rope, tethering the Alien to the shuttle and getting the harpoon gun stuck against the door. The Alien then tried to get back in via the engine, but Ripley hit the ignition and the creature was incinerated. Ripley and Jones then went into stasis for the journey home.
Later when a salvage team discovered the Narcissus, still drifting through space after 57 years, the harpoon gun was still stuck against the door as it had been 57 years ago. Exactly what happened to the harpoon gun after the salvage team discovered the Narcissus is unknown. However it was likely taken as evidence to be used against Ripley during the tribunal into the destruction of the Nostromo.
It seems strange that a harpoon gun would be aboard a space shuttle. Ridley Scott said in an Alien commentary that it was perhaps used for docking or as a piece of safety equipment.
The harpoon gun made a reappearance in Aliens — just before the robotic arms cuts through the Narcissus hatch at the beginning of the film, the gun can be glimpsed wedged beneath the door, just where it ended up at the conclusion of Alien.
In the June 1979 script for Alien and in the novelization of the film, the harpoon gun does not exist; instead, after Ripley puts on the space suit she arms herself with a metal spear, which she uses to impale the Alien before opening the airlock, sending the Alien into space, without the need to shoot it with the harpoon gun.