We present a new technique for computing the electromagnetic field that propagates and is scattered in three-dimensional structures formed by bodies embedded in a stratified background. This fully vectorial technique is based on the Green's tensor associated with the stratified background. Its advantage lies in the fact that only the scatterers must be discretized, the stratified background being accounted for in the Green's tensor. Further, the boundary conditions at the different material interfaces as well as at the edges of the computation window are perfectly and automatically fulfilled. Several examples illustrate the utilization of the technique for the modeling of photonic circuits (integrated optical waveguides), the study of the optics of metal (surface plasmons), and the development of new optical lithography techniques. (C) 2001 Optical Society of America.