Near-infrared lasers are important for optical data communication, spectroscopy and medical diagnosis. Semiconductor nanowires offer the possibility of reducing the footprint of devices for three-dimensional device integration and hence are being extensively studied in the context of optoelectronic devices. Although visible and ultraviolet nanowire lasers have been demonstrated widely, progress towards room-temperature infrared nanowire lasers has been limited because of material quality issues and Auger recombination. (Al)GaAs is an important material system for infrared lasers that is extensively used for conventional lasers. GaAs has a very large surface recombination velocity, which is a serious issue for nanowire devices because of their large surface-to-volume ratio. Here, we demonstrate room-temperature lasing in core-shell-cap GaAs/AlGaAs/GaAs nanowires by properly designing the Fabry-Pérot cavity, optimizing the material quality and minimizing surface recombination. Our demonstration is a major step towards incorporating (Al)GaAs nanowire lasers into the design of nanoscale optoelectronic devices operating at near-infrared wavelengths.