Yes.
http://support.apple.com/kb/HT3924
Summary
With Target Display mode, you can use your 27-inch iMac with Mac OS X as an external display. Connect any computer or other device with a Mini DisplayPort to your 27-inch iMac using a Mini DisplayPort to Mini DisplayPort cable or using a converter that converts other electrical, video, and audio protocols from another source device to Mini DisplayPort compliant signals. (Cables and converters available separately.)
To use a 27-inch iMac in Target Display mode with another computer as the source:
Make sure both computers are turned on and awake.
Connect a male-to-male Mini DisplayPort cable to the Mini DisplayPort on each computer. The 27-inch iMac will enter Target Display mode and display content from the source computer.
Note: If you are connecting two 27-inch iMacs, connect a Mini DisplayPort cable to each computer and press Command + F2 on the 27-inch iMac keyboard that you will use as an external display.
To leave Target Display mode, press Command + F2 on the keyboard of the 27-inch iMac that is in Target Display mode. To return to Target Display mode, press Command + F2 again.