A critical moment in the detection process of incoming target at sea occurs, when a target just appears above the horizon. The corresponding light rays cross the atmospheric boundary layer, in which the presence of temperature gradients may result in optical distortion effects. This geometric distortion implies propagation effects such as the variation of the angle of arrival of the horizon line, a change in the shape of an extended target, the possible presence of mirages and enhanced or decreased atmospheric transmission or apparent radiant intensity of a point target. This situation is becoming even more complex, when the temperature profile is not constant over the path length, which is likely to be the case in coastal areas with tidal currents. Another effect causing complexity is the presence of surface waves, introducing a vertical motion in the marine boundary layer. All these effects may have an impact on the detection performance of optical and infrared sensors for detection and identification of targets near the horizon. Presently available propagation models are unable to predict accurately the effect of the phenomena on the propagation of surface grazing light beams. A new and accurate ray-tracing model has been developed, allowing quantitative predictions of the various propagation effects for a given profile of the temperature. This model, capable to take into account the dimensions of the target and the receiver aperture, is described in the paper. The ray tracing in the model is based upon the Huygens-Fresnel principle, in contrary to other models, where a layered atmosphere is used. Examples are given of the effect of different temperature profiles and comparisons of predictions are made with data from field measurements.