The Sun is the most energetic natural particle accelerator in the solar system. Observations of g-ray lines produced by accelerated ions and of hard X-ray (HXR)/g-ray continuum emission produced by accelerated electrons show that ions are accelerated up to ~GeV energies and electrons up to ~100s of MeV, respectively, in large solar flares. Following such flares, ions and electrons up to comparable energies are often detected near 1 AU in intense, gradual solar energetic particle (SEP) events, but these appear to be accelerated by shocks driven by associated fast coronal mass ejections (CMEs) and not by flares. Large solar flares release up to ~1032 ergs in 100-1000 s, with >~10-50% of this energy going to accelerating > tens of keV electrons and > several MeV ions. Imaging of the hard X-ray (HXR)/gamma-ray continuum and gamma-ray line emission produced by the accelerated electrons and ions, respectively, by the RHESSI (Ramaty High Resolution Solar Spectroscopic Imager) mission, show that magnetic reconnection underlies both the flare energy release and particle acceleration. Direct in situ measurements by the Wind and Cluster spacecraft also show that electron acceleration up to ~300 keV also occurs in the magnetic reconnection region of the Earth.s magnetotail. For flares, the >0.3 MeV electron bremsstrahlung continuum and 2.223 MeV neutron-capture line fluences exhibit a close linear correlation over >3 orders of magnitude in flare intensities, strongly suggesting a common flare acceleration process for relativistic electrons and >30 MeV ions. The inferred e/p ratios (0.5 MeV electrons to 10 MeV protons) for these gamma-ray line flares are about 100 times those for gradual SEP events but comparable to those measured for the frequent, but generally small, impulsive solar energetic particle (SEP) events that exhibit strong enhancements of 3He, and heavy ions. Recent results from theory and simulations of magnetic reconnection, have led to significant progress in understanding these particle acceleration phenomena.