Fast radio bursts (FRBs) are short (millisecond) radio pulses originating from enigmatic sources at extragalactic distances so far lacking a detection in other energy bands. Magnetized neutron stars (magnetars) have been considered as the sources powering the FRBs, but the connection is controversial because of differing energetics and the lack of radio and X-ray detections with similar characteristics in the two classes. We report here the detection by the AGILE satellite on April 28, 2020 of an X-ray burst in coincidence with the very bright radio burst from the Galactic magnetar SGR 1935+2154. The burst detected by AGILE in the hard X-ray band (18-60 keV) lasts about 0.5 seconds, it is spectrally cutoff above 80 keV, and implies an isotropically emitted energy ~ $10^{40}$ erg. This event is remarkable in many ways: it shows for the first time that a magnetar can produce X-ray bursts in coincidence with FRB-like radio bursts; it also suggests that FRBs associated with magnetars may emit X-ray bursts of both magnetospheric and radio-pulse types that may be discovered in nearby sources. Guided by this detection, we discuss SGR 1935+2154 in the context of FRBs, and especially focus on the class of repeating-FRBs. Based on energetics, magnetars with fields B ~ $10^{15}$ G may power the majority of repeating-FRBs. Nearby repeating-FRBs offer a unique occasion to consolidate the FRB-magnetar connection, and we present new data on the X-ray monitoring of nearby FRBs. Our detection enlightens and constrains the physical process leading to FRBs: contrary to previous expectations, high-brightness temperature radio emission coexists with spectrally-cutoff X-ray radiation.