LOFAR offers a unique possibility in particle astrophysics for studying the origin of high-energy cosmic rays (HECRs) at energies between 10 to the power 15 - 10 to the power 20.5 eV. Both the sites and processes for accelerating particles are unknown. Possible candidate sources of these HECRs are shocks in radio lobes of powerful radio galaxies, intergalactic shocks created during the epoch of galaxy formation, so-called hypernovae, gamma-ray bursts, or decay products of super-massive particles from topological defects, left over from phase transitions in the early universe. The primary observable is the intense radio pulse that is produced when a primary CR hits the atmosphere and produces an Extensive Air Shower (EAS). An EAS is aligned along the direction of motion of the primary particle, and a substantial part of its component consists of electron-positron pairs which emit radio emission in the terrestrial magnetosphere (e.g., geo-synchrotron emission). At the high Lorentz factors considered here, the cascade is confined to a slab of only a few meters thickness. As a result, the EAS emits coherent radiation below 200 MHz. From the arrival times and intensities of the radio pulse at the individual antennas of LOFAR, the direction of the primary particle can then be accurately determined. Recently, the radio signal from cosmic rays has been detected with a LOFAR prototype station (LOPES). Also, a first Monte Carlo code has been developed that simulates the emission process and can be used together with the experiment. Thus LOFAR will allow several fundamental new observational studies of HECRS: * The study of HECRs in the entire interval from 10 to the power 15 eV up to 10 to the power 20.5 eV is possible with the same instrument at almost 100% duty cycle. For comparison, standard techniques in the optical (Cherenkov or fluorescence emission) have only a 10% duty cycle (with new moon and at night), and allow observations in only a relatively narrow range of primary energies; * The time evolution of the LOFAR signal will allow direct observation of the poorly understood development of the electromagnetic part of the cascade by observing the radio emission in the source. In particular the height of the shower maximum can be measured. Furthermore, it will allow determination of forward cross-sections and inelasticity parameters which cannot be measured in particle colliders because of the geometry of two interacting beams which excludes detectors on the beam axis; * High-energy (>10 to the power 18 eV) neutrons can cross the Galaxy before they decay and thus the discovery of point-sources becomes possible. Discrimination between anisotropies caused by neutrons and by charged nuclei (which are affected in their propagation by the Galactic magnetic field) is in principle possible by studying the absence or presence of anisotropies at lower energies; * Measurement of the composition of HECRs from the study of simultaneous pairs of showers at a distance up to several 100 km. Such 'multiplet' events are expected from photo-disintegration of CRs in the solar radiation field (Gerasimova-Zatsepin effect); * Detection of high-energy neutrinos (10 to the power 15 10 to the power 18 eV) in horizontal showers, and of tau neutrinos ('double-bang' events: two showers at 50 km distance); * Detection of neutrinos from their radio emission generated in the lunar surface regolith.