Overview: What is Guild XP?
Guild XP is used to level up the guild you are in. Guilds start at level 1 and can move up to level 25 (and eventually level 30 sometime at an unannounced point in the future) by earning enough Guild XP. The amount of Guild XP required to level up your guild, and the perks you can earn at each level, are listed here:
Whenever you do an activity that qualifies for Guild XP, your current guild will earn that much Guild XP.
Starting with patch 5.0.4, there is no longer any cap on how much Guild XP your guild can earn each day. You could theoretically advance from level 1 to level 25 in one day if your guild was extremely productive.
You can hit the j key (by default) to see your guild information screen. This screen shows what level your guild is, how much Guild XP has been earned so far today, and the guild's progress towards its next guild level. Perks are also shown at the bottom.
You can right-click on your chat tab and select "Settings" under Filters, then click "Other" and then select the box to show Guild XP gains. (Default color is blue.) Then you'll see a chat line whenever you do something that grants Guild XP.
What about Guild Levels 26-30?
Originally Mists of Pandaria was going to allow guilds to level up from 25 to 30. There are even traces of this still visible in the game, such as listings for Realm First Level 30 Guild.
However, in the Best Buy Dev interview (http://www.mmo-champion.com/content/2932-Best-Buy-Developer-Q-A), the developers stated:
"We are totally open to increasing guild levels and the associated rewards but only when the game feels like it needs more of that content. A large number of guilds are still nowhere near level 25 so Mists did not feel like a good fit to add more guild levels."
How to Earn Guild XP
The following five activities earn Guild XP:
1. Turning in quests -- see below.
2. Killing a raid or dungeon instance boss when in a guild group -- see next post, and amounts in post after next.
3. Arena wins when in a guild group -- see next post.
4. Rated Battlegrounds wins when in a guild group -- see next post.
5. Earning honor in battlegrounds -- see next post.
No other activities earn Guild XP. Leveling your professions or reputation, archaeology, killing world mobs or rare mobs, earning achievements, clearing trash or mini-bosses in dungeons or raids, grinding mobs -- all of that counts for zero Guild XP.
(Outdoor raid bosses will need to be confirmed. Previously they awarded nothing, but they're a bigger deal in MoP, and there are some new systems.)
Source 1: Guild XP from Quests
Prior to 5.0.4, 25% of the amount of XP you earned (or would earn if you weren't max level) was also earned as Guild XP by your guild. This meant that low-level characters contributed nearly nothing to guild leveling.
Starting with 5.0.4, the amount of Guild XP for quest turn-ins by low-level characters is similar to high-level. The exact formula appears to be 60k Guild XP for every level-appropriate quest. (Many thanks to Bigcheif, Kvöthe, and Nyssa on pages 7-8 of this thread for providing this data.)
It appears that any quests that are too low for your character to earn XP will earn zero Guild XP.