This paper proposes OptMark, a robust multi-bit watermarking method for copyright protection and user tracking of images generated using diffusion models. To overcome the limitations of existing methods, such as limited capacity and vulnerability to transformations and attacks, OptMark strategically embeds structural and detail watermarking into the intermediate latent variables of the diffusion noise removal process using an optimization-based approach. This ensures robust resistance to generative attacks and image transformations, while preserving image quality and rendering the watermark imperceptible. Furthermore, we improve memory efficiency by reducing memory usage from O(N) to O(1) using adjoint gradient methods. Experimental results demonstrate that OptMark achieves robust, unobtrusive multi-bit watermarking while remaining resilient to various transformations and attacks.