From iA wiki
A Web browser developed for MacOS X by Apple and its developer community based on KHTML and KJS technologies that were developed by the K Desktop Environment (KDE) project for their Konqueror web browser. Safari, which has reached 1.2, contains many features and tools and is free for download from the Apple Web site.
Apple decided to develop their own browser based on an open source rendering engine. After recruiting some of the more brilliant minds of the open source browser world (mostly Mozilla hackers) and researching the available options Apple decided use KHTML from the KDE project. The project lead specifically cited that KHTML was chosen because of its small code size, which in turn increased Safari's speed, simpified porting and eased code manageability. At the time KHTML would only run under KDE and was in the process of being ported to Apple's latest operating system but was not finished. Apple wrote a complete porting and wrapping environment called WebCore to host KHTML. The Apple Safari group also donated many fixes and improvments to KHTML's main source tree while keeping current with updates by the KHTML people. As such both software projects have gained from the cooperation, to the benefit of both KDE and MacOS X users.
There was some controversy within the community about why Safari was not based on Gecko, Mozilla's standards-compliant but slightly slower browser technology. It was argued that Safari will never achieve a strong marketshare as it is not as cross-platform capable as Mozilla which is available for more operating systems than almost any other browser. However, as a consequence, the Mozilla community decided to speed up the Browser by breaking it into parts: Firebird and Thunderbird - no longer using a large browsing suite. No word on whether or not Apple will embrace Mozilla once it implements this system.
Note that Safari has integrated various portions of the Mozilla codebase.