We report the first experimental demonstration of longitudinal compression of laser-accelerated electron pulses. Accelerated by a femtosecond laser pulse with an intensity of 10¹⁸ W/cm², an electron pulse with an energy of around 350 keV and a relative momentum spread of about 10⁻² was compressed to a 500-fs pulse at a distance of about 50 cm from the electron source by using a magnetic pulse compressor. This pulse was used to generate a clear diffraction pattern of a gold crystal in a single shot. This method solves the space-charge problem in ultrafast electron diffraction.