Standoff at the Great Sept of Baelor

The standoff at the Great Sept of Baelor is an unsuccessful attempt by House Tyrell and House Lannister to crack down the Faith Militant. The plan was meant to force the release of Margaery Tyrell from imprisonment with the threat of military force. Although the army of House Tyrell is significantly stronger than the Faith Militant, the assault was called off when King Tommen Baratheon supported the Faith. This was a significant blow to the then two most powerful houses in Westeros.

Background
As part of her powerplay with the Tyrells, Cersei Lannister allowed the creation of the Faith Militant, which promptly arrested Loras Tyrell for his homosexual relationship with Renly Baratheon. In an effort to help her brother, Margaery Tyrell denied knowledge of this, in turn resulting in her own arrest.

Initially a victory for Cersei, tables quickly turned when she was arrested herself for her incestual relationship with her brother Jaime Lannister. After she was forced to make a Walk of atonement, she realized the Faith Militant had become too powerful.

Fearing for Queen Margaery's safety, King Tommen Baratheon orders his Hand of the King, Kevan Lannister, to take no action against the Faith Militant. This does not prevent House Tyrell from taking action on their own, however, so they hatch a plan in which Mace Tyrell will lead an army to storm the Great Sept while the City Watch stands down.

Standoff
Spearheaded by Jaime, the Tyrell force arrives the moment Margaery's humiliation is about to commence, blocking off the stairway of the Great Sept of Baelor from the street below. While claiming the Faith Militant is unafraid to die for the gods, the High Sparrow cancels the walk of atonement, before revealing the recruitment of King Tommen himself into the Faith. Tommen presumes to declare an alliance between the Iron Throne and the Faith. Olenna Tyrell bitterly notes that the High Sparrow has beaten them.

Aftermath
Olenna Tyrell wastes no time leaving King's Landing and encourages Cersei to do the same, scolding her for causing the trouble in the first place. Cersei is unprepared to give up, however, and elects to stay with her son and attempt to regain her position.

In the books
In the A Song of Ice and Fire novels, no such encounter ever takes place.

In the fifth novel, Mace Tyrell and Randyll Tarly bring their armies to King's Landing, but they do not attempt to free Margaery by force, nor do they need to: since the case against Maraegry and her cousins is very weak, nearly all the testimonies against them - whom Cersei "arranged" - turned to be false (the witnesses have lied either willingly or under coercion), the High Sparrow agrees to hand the girls over to Tarly’s custody. Randyll swears a holy oath to deliver them for trial when the time comes.

Mace demands Kevan clear the charges against Maraegry by having Tommen declare her innocence, but Kevan refuses. Kevan also suspects the charges are false, but believes it is better to hold the trial, otherwise the whispers will follow Margaery the rest of her life. He answers Mace politely "No man doubts your daughter’s innocence, my lord, but His High Holiness insists upon a trial.” He reminds Mace and Randyll that they have foes on every hand (Stannis in the north, ironmen in the west, sellswords in the south), and if they defy the High Septon, they will have blood running in the gutters of King’s Landing as well; if they are seen to be going against the gods, it will only drive the pious into the arms of one or the other of those would-be usurpers.

At that point, Jaime is not at King's Landing. He has already marched to Riverrun, and has no idea about Margaery's arrest.

Olenna is not present either. She has left the city shortly after Tommen and Margaery's wedding, and has not returned by the point the books reached.