The definition above by
tongpoo is valid, but there's some more that should be said about
compactness.
There are actually two very different definitions of compactness:

A subset E of a metric space X is said to be HeineBorel compact if for every open cover {G_{i}}, there exists a finite list of indices a_{1},a_{2},...,a_{k} such that {G_{a1},G_{a2},...,G_{ak}} covers E. This says just what tongpoo's definition above says: that every open cover of E can be reduced to a finite open cover.

On the other hand, E is said to be WeierstrassBolzanno compact if every infinite subset S of E has a limit point in E.
As it turns out, these two properties are in fact equivalent; the proof is pretty involved, so I won't include it here.
Note: (sorry for splitting hairs here)
The HeineBorel Theorem is slightly weaker than the statement in tongpoo's writeup. It actually states that a subset S of R^n is compact iff it is closed and bounded.
This is not necessarily true of metric spaces in general. For example, consider the metric space Q, the rational numbers, with the metric d defined by d(p,q)=pq. In this metric space, the set E := {p in Q  2 < p^2 < 3}, i.e. the set of rational numbers between sqrt(2) and sqrt(3), is in fact both closed and bounded, but not compact. Since sqrt(2) is not in the metric space Q, it is not a limit point of E. However, it is not hard to see that we could construct an infinite subset of E with limit point sqrt(2); since sqrt(2) is not in E, this would violate the WeierstrassBolzanno property above, so that E is not compact.
It's hard to know if I've been clear in this writeup. Please /msg me and let me know either way.