That brings up a good question: Do you drink a lot of water? Water does many things to help nourish your system, plus it has been documented that the heavier people are, the more water they require for health purposes.
When shifting up your diet back to more calories, were you still working out a lot? And ratbastid's right, you can't gain fat that fast, it was probably water weight from the additional carbs in your system. Also remember that not drinking enough water causes you to retain water, just like undereating causes you to retain fat.
Consider these as a guideline:
- Eat balanced nutrients (protein/carbs/fats) as others have listed above;
- Eat a caloric intake reasonable for your gender/height/weight (likely to be at least 2,000, if not 2,500);
- Eat foods that balance your blood sugar and provide long-term energy (oatmeal, legumes, etc.);
- You might want to cut out some heavier meats, replacing them with vegetarian alternatives;
- Cut out sugar;
- Drink at least a litre of water per day, but up to two litres if you exercise a lot;
- Continue to lift weights to build muscle (muscle boosts your metabolism, even at rest, but you need adequate calories and protein to build it);
- Do interval training for cardio exercise (fat-burning cardio burns fat mostly during the session, while interval training burns far more calories as your body recovers over the next several hours);
- Do all of this with the help of a fitness trainer and nutritionist;
- Stick to your goals, work hard, and don't use your weight as your only progress indicator.