This phrase is popularly attributed to this scene from
The Godfather Part II.
Michael Corleone talking to
Frankie Pentangeli to arrange a meeting with the
Rosato brothers right after Michael was almost
assassinated:
Michael: It was
Hyman Roth that tried to have me killed. I know it was him.
Frankie: Jesus Christ, Mike, Jesus Christ, look, let's get them all.
Let's hit them all. Now while we got the muscle...
Michael: ...My father taught me many things here - he taught me in this room. He taught me -
keep your friends close but your enemies closer. Now if Hyman Roth sees that I interceded in this thing, in the Rosato Brothers' favor, he's going to think his relationship with me is still good...That's what I want him to think. I want him completely relaxed and confident in our friendship. Then I'll be able to find out who the traitor in my family was.
However I've seen it other places - Sun Tzu wrote this in The Art of War: To know your enemy, you must become your enemy... Keep your friends close and your enemies closer.