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.
http://www.everything2.com/index.pl?node_id=134222
Yes, I remember it well. Have seen all three parts. Excellent. Loved it. The food, the culture, the ways of the family and all of it (except the violence of course) Felt like I was right there and back home in New Jersey at my familie's table eating spaghetti and meat balls, drinking wine and eating hard cheese, Calamatta, Italian bread, cookies, and all the wonderful goodies my mother and grandmother used to make back in the old days. It was right on!!! Congratulations Justice Samuel (my uncle's name) Alito! :)