Context. The study of exoplanetary atmospheres is key to understanding the differences between their physical, chemical, and dynamical processes. Until now, the bulk of atmospheric characterization analyses have been conducted on transiting planets. On a number of sufficiently bright targets, high-resolution spectroscopy (HRS) has also been successfully tested for nontransiting planets mainly by using spectrographs mounted on 8 and 10 m class ground-based telescopes. Aims. The aim of this analysis is to study the dayside of the nontransiting planet HD 102195b using the GIANO spectrograph mounted at the Telescopio Nazionale Galileo (TNG), and thereby demonstrate the feasibility of atmospheric characterization measurements. In particular, we wish to demonstrate the possibility of molecular detection with the HRS technique for nontransiting planets using 4 m class telescopes. Methods. Our data-analysis technique exploits the fact that the Doppler-shifted planetary signal changes on the order of many kilometers per second during the observations, in contrast with the telluric absorption which is stationary in wavelength. This allows us to effectively remove the contamination from telluric lines in the GIANO spectra while preserving the features of the planetary spectrum. The emission signal from the atmosphere of HD 102195b is then extracted by cross-correlating the residual GIANO spectra with models of the planetary atmosphere. Results. We detect molecular absorption from water vapor at the 4.4σ level of statistical significance. We also find convincing evidence for the presence of methane, which is detected at the 4.1σ level. This is the first detection of methane obtained with the HRS technique. The two molecules are detected with a combined significance of 5.3σ, at a semi-amplitude of the planet radial velocity KP = 128 ± 6 km s−1. We estimate a true planet mass of MP = 0.46 ± 0.03 MJ and constrain the orbital inclination in the range 72.5° < i < 84.79° (1σ). Our analysis indicates a noninverted atmosphere for HD 102195b. This is expected given the relatively low temperature of the planet, inefficient to keep TiO/VO in gas phase. Moreover, a comparison with theoretical model expectations corroborates our detection of methane, and a cursory confrontation with chemical model predictions published in the literature suggests that the detected methane and water signatures could be consistent with a low C/O ratio for HD 102195b. Finally, as HD 102195 is one to three magnitudes fainter in the K-band than the nontransiting systems studied until now with 8 m telescopes, our study opens up the possibility for atmospheric characterization of a larger sample of exoplanets.