We present new echelle spectrophotometry of the Galactic H II regions M8 and M17. The data have been taken with the VLT UVES echelle spectrograph in the 3100 to 10400 angstroms range. We have measured the intensities of 375 and 260 emission lines in M8 and M17 respectively, increasing significatively the number of emission lines measured in previous spectrophotometric studies of these nebulae. Most of the detected lines are permitted lines. Electron temperatures and densities have been determined using different diagnostics. We have derived He+, C++, O+ and O++ ionic abundances from pure recombination lines. We have also derived abundances from collisionally excited lines for a large number of ions of different elements. Highly consistent estimations of t2 have been obtained by using different independent indicators, the values are moderate and very similar to those obtained in other Galactic H II regions. We report the detection of deuterium Balmer emission lines, up to D$\epsilon$, in M8 and show that their intensities are consistent with continuum fluorescence as their main excitation mechanism.