While artificially fabricated patterned metasurfaces are providing paradigm-shifting optical components for classical light manipulation, strongly interacting, controllable, and deterministic quantum interfaces between light and matter in free space remain an outstanding challenge. Here we theoretically demonstrate how to achieve quantum control of both the electric and magnetic components of an incident single-photon pulse by engineering the collective response of a two-dimensional atomic array. High-fidelity absorption and storage in a long-lived subradiant state, and its subsequent retrieval, are achieved by controlling classically or quantum mechanically the ac Stark shifts of the atomic levels and suppressing the scattering during the absorption. Quantum wavefront control of the transmitted photon with nearly zero reflection is prepared by coupling the collective state of the array to another photon in a cavity and by engineering a Huygens' surface of atoms using only a single coherent standing wave. The proposed schemes allow for the generation of entanglement between the cavity, the lattice, and hence the state of the stored, reflected or transmitted light, and for quantum-state transfer between the cavity and propagating photons. Bipartite entanglement generation is explicitly calculated between a stored single-photon excitation of the array and the cavity photon. We illustrate the control by manipulating the phase, phase superposition, polarization, and direction of a transmitted or reflected photon, providing quantum-optical switches and functional quantum interfaces between light and atoms that could form links in a larger quantum information platform.