A hypothesis test consists of a test statistic, and a rejection region -- those values of the test statistic for which you will reject the null.
Take as a given that we have some test where if the null hypothesis were true we can calculate (or at worst approximate very well) the distribution that the test statistic would have.
Also take as a given that we know what kinds of values of the test statistic will tend to occur more often if the null was false.
This then allows us to specify which values of the test statistic we would regard as "unusual"or "surprising" if the null were true -- those that would be (collectively) unlikely to occur if the null were true but more likely under the alternative.
For a simple example, imagine testing a mean in a situation where we have a good model for the distribution of the statistic when H0 is true. Here's an example:
Waiting times until certain kinds of events occur often have something very like an exponential distribution. So imagine we are interested in testing a hypothesis about waiting times and let us take that exponential distribution as a model for our population.
In our situation, we're examining a claim that the average waiting time is no more than 1 hour.
$H_0: \mu\leq 1$
$H_1: \mu > 1$
(assuming our unit of time is in hours)
A suitable test statistic might be the mean (or something based on the mean), since (a) the population mean is the quantity of interest and (b) the sample mean is a good way to estimate the population mean when you're sampling an exponential distribution.
Then clearly if population waiting times are more than 1 hour we expect to see higher sample means than if population waiting times are less than 1 hour. We will regard long average waits in the sample as surprising if the true population waiting time is no more than 1 hour.
That is, we want to reject the null hypothesis if the sample mean waiting time is very large and not to reject the null if the mean waiting time is not very large.
We just have to figure out where to draw the border of that rejection region.
If the null is true the "worst" case for us (hardest to distinguish from the alternative) occurs when the population wait time is exactly 1 hour (in that for any specific cut-off between rejection and non-rejection, the type I error rate will be highest then; if we satisfy ourselves that the type I error rate is not too high at that value of $\mu$ we will not do any worse at any other value of $\mu$).
Now imagine that we are going to obtain n=22 times for our sample. In this case (taking the null worst-case $\mu=1$hr) we can calculate the distribution of $\bar{X}$ for a sample of size 22 exactly; it turns out to have what's called a gamma distribution with shape parameter 22 and scale parameter 1/22 (or rate parameter 22). It (unsurprisingly!) has mean 1 (i.e. 1 hour).
Most computer packages for statistics will have this gamma distribution function built in, but if this were not available, we can use chi-squared tables (with 44 degrees of freedom in this example) to obtain what we need with only a little additional effort.
Imagine further that we want our type I error rate not to exceed 1%; this can be satisfied if we take the rejection region to be the upper 1% of that gamma distribution.
So where do critical values come in?
A critical value simply represents the border between the rejection region and the non-rejection region (though it's specifically in the rejection region).
The 0.99 percentile of that gamma distribution is just what is required to divide between those sample values we want to say are inconsistent with the null (whose mean is "too large" to be credible) from those than are not. This cut-off is 1.5616, as it turns out. (If you're using chi-squared tables, the 99th percentile or upper 1% critical value of the $\chi^2_{44}$, divided by 44 also gives 1.5616)
So our rejection region for this test (given n=22) is any sample mean that is $\geq 1.5616$ (hours) and we would not reject the null for any smaller value.
We call this threshold value the critical value.
It's not always the case that we reject for large values of a test statistic and fail to reject for small values; it depends on the test -- but you can always examine which values are relatively more likely under the alternative to figure out where you want your rejection region to be placed so as to reject the cases most consistent with the alternative (relative to the null).