Body of Lies
(2008)

Roger Ferris (Leonardo DiCaprio) is a CIA operative stationed in the Middle East pursuing an Al-Qaeda like terrorist cell, led by a man named Al-Saleem, guided by his manipulative handler, Hoffman (Russell Crowe). Ferris finds a lead in Jordan and cooperates with the shady head of local intelligence, Hani (Mark Strong). He even finds time to romance a local nurse.
 
Eventually, Ferris comes up with a plan: set up a local architect as the head of a rival terrorist cell without his knowledge, which will force Al-Saleem to come out of hiding. The plan backfires, however, and the architect ends up dead. Ferris' cover is blown and the nurse gets abducted by the terrorists, who want Ferris in exchange. He agrees, and gets taken prisoner to a remote location.
 
It turns out, however, that the nurse was never abducted; she was taken by Hani and his men, as part of a plan to capture Al-Saleem by using Ferris as bait (Hani had a man undercover in Al-Saleem's outfit, against his will, who led them to the location). Ferris gets tortured and just as he's about to be killed, Hani's team arrives and saves his life, and Saleem gets arrested.
 
Hoffman offers Ferris a desk job back at Langley, but the agent decides he's had enough and he's leaving the agency. Ferris stays in Jordan, intent on reconciling with the nurse. The final scene shows Hoffman calling off the satellite surveillance on Ferris, respecting his decision to quit. 
 

Thanks Ernesto!