Let \( x \) be the number of games Ahmadullah's basketball team played last season.
According to the problem, this season they will play 21 games, which is 12 games more than \( \frac{1}{3} \) of the number of games they played last season. We can write this as an equation:
\[ 21 = \frac{1}{3}x + 12 \]
Next, subtract 12 from both sides of the equation to get:
\[ 21 - 12 = \frac{1}{3}x \]
\[ 9 = \frac{1}{3}x \]
Now, to solve for \( x \), multiply both sides by 3:
\[ x = 9 \times 3 \]
\[ x = 27 \]
Thus, the number of games that Ahmadullah's basketball team played last season is \( \boxed{27} \).