We investigate the long-term evolution of black hole accretion disks formed
in neutron star mergers. These disks expel matter that contributes to an
$r$-process kilonova, and can produce relativistic jets powering short
gamma-ray bursts. Here we report the results of a three-dimensional,
general-relativistic magnetohydrodynamic (GRMHD) simulation of such a disk
which is evolved for long enough ($\sim 9$s, or $\sim 6\times 10^5 r_{\rm
g}/c$) to achieve completion of mass ejection far from the disk. Our model
starts with a poloidal field, and fully resolves the most unstable mode of the
magnetorotational instability. We parameterize the dominant microphysics and
neutrino cooling effects, and compare with axisymmetric hydrodynamic models
with shear viscosity. The GRMHD model ejects mass in two ways: a prompt
MHD-mediated outflow and a late-time, thermally-driven wind once the disk
becomes advective. The total amount of unbound mass ejected ($0.013M_\odot$, or
$\simeq 40\%$ of the initial torus mass) is twice as much as in hydrodynamic
models, with higher average velocity ($0.1c$) and a broad electron fraction
distribution with a lower average value ($0.16$). Scaling the ejected fractions
to a disk mass of $\sim 0.1M_\odot$ can account for the red kilonova from
GW170817 but underpredicts the blue component. About $\sim 10^{-3}M_\odot$ of
material should undergo neutron freezout and could produce a bright kilonova
precursor in the first few hours after the merger. With our idealized initial
magnetic field configuration, we obtain a robust jet and sufficient ejecta with
Lorentz factor $\sim 1-10$ to (over)produce the non-thermal emission from
GW1708107.