In the standard model of solar flares, a large-scale reconnection current sheet is postulated to be the central engine for powering the flare energy release$^1-3$ and accelerating particles$^4-6$. However, where and how the energy release and particle acceleration occur remain unclear owing to the lack of measurements of the magnetic properties of the current sheet. Here we report the measurement of the spatially resolved magnetic field and flare-accelerated relativistic electrons along a current-sheet feature in a solar flare. The measured magnetic field profile shows a local maximum where the reconnecting field lines of opposite polarities closely approach each other, known as the reconnection X point. The measurements also reveal a local minimum near the bottom of the current sheet above the flare loop-top, referred to as a `magnetic bottle'. This spatial structure agrees with theoretical predictions$^1,7$ and numerical modelling results. A strong reconnection electric field of about 4,000 V m$^-1$ is inferred near the X point. This location, however, shows a local depletion of microwave-emitting relativistic electrons. These electrons instead concentrate at or near the magnetic bottle structure, where more than 99% of them reside at each instant. Our observations suggest that the loop-top magnetic bottle is probably the primary site for accelerating and confining the relativistic electrons.