These both mean "two", and are used as follows.
When "2" is followed by a measure word, use 兩:
兩個人, 兩本書, 增加了兩倍, 去了兩次
二 should be used in a number greater than 10, even if it is followed by a measure word:
二十二, 一百零二次, 十二個人, 五千八百六十二元
There are some more restrictions, though:
Only 二 can be used before the character 十; before the character 百, 二 is usually employed but 兩 may also be used:
二十, 二百二十五, 二百五十元 or 兩百五十元
For numbers like 千, 萬 or 億, 兩 is used more often than 二:
兩千元 (also 二千元), 兩萬三千八, 兩億人口
If the number is greater than 百, 千, 萬, /i.e./ if there are more digits before 百, 千 or 萬, then put 二 instead of 兩 in front:
四億二千萬, 三萬二千人, 五千二百元