Many other answers have covered lights for seeing on the ground, which are invaluable during taxiing, takeoff and landing.  They've also covered how most obstacles (like other planes) should be illuminated to be seen (according to [Advisory Circular 70/7460-1L][1] in the US).  I'm going to cover the other ways that an aircraft can "see" what's around it. IFR navigation and [avoiding controlled flight into terrain][2] are a related topic.

The answer depends somewhat on whether we're talking about visual flight rules or instrument flight rules.  Visually spotting lit obstacles is far more important if you're not instrument-rated.   Of course, *planes don't have to visually see obstacles to avoid them*. Properly trained pilots can fly IFR in zero visibility, so they have plenty of tools to identify threats ahead that they can't see.

Charts
------
Aircraft can fly in low visibility situations where even lights won't do you much good.  This is done in large part using careful navigation and reference to charts.  Sectional charts are required to show peaks, towers, and other obstructions as shown in the legend below.  Approach plates and procedures may also list smaller obstacles particularly close to the runway.
[![How obstacles are marked on sectional charts][3]][3]

You'll notice that the sectional below has the obstructions marked as well as a big 07 in the right hand bottom.  That 07 means that the highest terrain or obstruction in the right hand box east of Logan Intl Airport) on the sectional is 700 feet, so if you're flying safely above that altitude you can avoid obstacles.  

[![Sectional chart excerpt for Boston][4]][4]

Synthetic Vision
----------------
A new emerging technology is [synthetic vision][5], as mentioned in SierraSkyport's answer.  This system combines precision location information with very detailed terrain and obstacles databases to provide a view of the surrounding area.  
This is sometimes combined an [enhanced vision system][6] with an near-IR camera to see in darkness and through fog and clouds, and this clear camera-based view of the surrounding area is often overlaid on the center of the synthetic vision display.  I've seen a near-IR camera in action and you can actually make out features like the edge of the runway and buildings, even in very low visibility.
[![Synthetic vision system][7]][7]
(Image by Honeywell, provided with Permission)

TCAS and ADS-B
----
You major obstacles when above the ground are other aircraft (I don't know what else you'd hit in the air, [meteorites][8]?) Any aircraft equipped with a mode-C or mode-S transponder is "visible" to a plane with TCAS, and the TCAS system will provide traffic alerts for nearby aircraft (and guidance for how to resolve the conflict if the intruder gets close enough and it's a TCAS II system).
[![TCAS Display][9]][9]

[ADS-B in][10] also provides traffic information for any nearby aircraft equipped with ADS-B out (which thanks to mandates is becoming very common).  ADS-B is often supplied integrated into a mode-s transponder, but this is not always the case, so you could have ADS-B out and ADS-B in but not a TCAS-compatible transponder.

TAWS, GPWS, and Radar altimeter
-------------------------------
For avoiding the ground these systems provide some information to avoid a controlled flight into terrain.  Terrain  awareness warning systems (TAWS) and ground proximity warning systems (GPWS) (the two are sometimes synonymous) are now required by the FAA on all large turbine and turbojets.  These systems warn if you're descending too fast, below the glideslope, or flying too close to terrain, based on a radar altimeter.  Even without this system, you may have a radar altimeter to monitor your height above terrain.

Radar
-----

[Weather Radar][11] (or Stormscopes) and ADS-B both provide excellent information about weather ahead that you can't see.  Most non-military aircraft [do not have primary radar][12] for seeing things other than weather. 

ATC
===
In a worst case scenario ATC has tools like minimum safe altitude warning systems and short-term conflict alerts and may alert you if you're about to run into terrain or another aircraft.  As far as I understand, this isn't supposed to be your primary method of avoiding obstacles though, even in IFR conditions.


  [1]: http://www.faa.gov/regulations_policies/advisory_circulars/index.cfm/go/document.information/documentID/1028657
  [2]: http://aviation.stackexchange.com/questions/22052/what-steps-can-pilots-take-to-mitigate-the-risk-of-controlled-flight-into-terrai/22073#22073
  [3]: https://i.sstatic.net/FcAsJ.jpg
  [4]: https://i.sstatic.net/byvBp.jpg
  [5]: https://en.wikipedia.org/wiki/Synthetic_vision_system
  [6]: http://aviation.stackexchange.com/questions/23722/what-is-an-enhanced-vision-system/23723#23723
  [7]: https://i.sstatic.net/FdBA0.jpg
  [8]: http://www.scientificamerican.com/article/is-it-possible-that-a-met/
  [9]: https://i.sstatic.net/oB4eG.jpg
  [10]: https://en.wikipedia.org/wiki/Automatic_dependent_surveillance_%E2%80%93_broadcast
  [11]: https://en.wikipedia.org/wiki/Weather_radar
  [12]: https://www.quora.com/Why-dont-commercial-aircraft-have-their-own-radar