A measurement of the electroweak (EW) production of two jets in association with a Z boson in proton-proton collisions at s=13TeV is presented, based on data recorded in 2016 by the CMS experiment at the LHC corresponding to an integrated luminosity of 35.9fb--1. The measurement is performed in the ℓℓjj final state with ℓ including electrons and muons, and the jets j corresponding to the quarks produced in the hard interaction. The measured cross section in a kinematic region defined by invariant masses mℓℓ>50GeV, mjj>120GeV, and transverse momenta pTj>25GeV is σEW(ℓℓjj)=534±20(stat)±57(syst) fb, in agreement with leading-order standard model predictions. The final state is also used to perform a search for anomalous trilinear gauge couplings. No evidence is found and limits on anomalous trilinear gauge couplings associated with dimension-six operators are given in the framework of an effective field theory. The corresponding 95% confidence level intervals are -2.6<cWWW/Λ2<2.6TeV-2 and -8.4<cW/Λ2<10.1TeV-2. The additional jet activity of events in a signal-enriched region is also studied, and the measurements are in agreement with predictions.