Edward II's nephew Gilbert de Clare, earl of Gloucester, though he had refused to help his brother-in-law Piers when the latter was imprisoned at Warwick Castle, offered to mediate between Edward and the earls. Gloucester, according to the Vita Edwardi Secundi (ed. Denholm-Young, pp. 33-4), told Edward that contrary to what he believed, the men who had had Piers killed were not his enemies but his friends, and that everything they did was for his own benefit. Edward - I feel like typing here 'Edward LOLed and went 'yeah riiiiight, pull the other one, mate, it's got bells on'' - was having none of it, and told his nephew "I protest that they are not my friends who strive to attack my property and my rights...it is very likely that they do not wish to have any consideration for me, but to seize the crown and set up for themselves another king." (For more of this conversation, see my Edward II: The Unconventional King, p. 77)
Other mediators on the king's side were his friend and ally Hugh Despenser the Elder (brother-in-law of the earl of Warwick but firmly on Edward's side, as always) and Robert, Lord Clifford, one of the men who had besieged Piers Gaveston at Scarborough Castle in May 1312 but who was otherwise loyal to Edward II. Edward's father-in-law Philip IV sent his half-brother Louis, count of Evreux, who at least before Edward's accession had been his good friend and frequent correspondent (and was his second cousin). Pope Clement V, real name Bertrand de Got, who like Piers Gaveston came from Gascony and had previously been archbishop of Bordeaux - Piers' uncle Piers or Pierre Caillau had been mayor of that city - also sent two envoys to negotiate between Edward and the earls. They were his chamberlain Arnaud d'Aux, bishop of Poitiers, and Cardinal Arnaud Nouvel, priest of Santa Prisca in Rome. Another negotiator was Edward II's first cousin John of Brittany, earl of Richmond, grandson of Henry III and brother of Duke Arthur II of Brittany (who died in August this year).
For all the best efforts of the negotiators, war threatened to break out throughout the summer and early autumn of 1312. In late September, Edward raised 1000 footmen in Kent and Sussex, and a few days later forbade the barons' envoys from entering London. (Patent Rolls 1307-1313, p. 498; Close Rolls 1307-1313, p. 481) Edward himself almost certainly wanted to fight, and some of his advisers, including his kinsman Henry, Lord Beaumont and his steward Sir Edmund Mauley, told him he should. (Seymour Phillips, Edward II, p. 193) Despite the threatening presence of their army at Ware in Hertfordshire, however, the earls did not enter London, though on 3 September Edward sent his brother-in-law Ralph Monthermer, the earl of Richmond, the bishop of Norwich and Sir Edmund Deincourt to prohibit them "from repairing to the king, as he understands they are doing, with horses and arms and a great body of armed men." (Patent Rolls 1307-1313, p. 490) Curiously, Edmund Fitzalan, earl of Arundel, is not mentioned in any of this, though appears to have been present at Warwick Castle and at Piers' murder. On 20 August, Gilbert de Clare, earl of Gloucester, was given permission to pass through London "with the horses of his household and his retinue with their horses, arms and armour" on Wednesday 23 August (Close Rolls, p. 475). Presumably this had something to do with him meeting the papal envoys, or the earls and their negotiators.
As Edward's academic biographer Professor Seymour Phillips points out (Edward II, p. 197), little is known about the negotiations themselves. Louis, count of Evreux arrived in London on 13 September, and dined with his niece Queen Isabella on the 15th; she was then seven months pregnant and had recently arrived in the south after a very slow journey from York, where Edward had left her at the end of June (presumably feeling that she would be safer there). On 17 September, Edward and Isabella retired to Windsor Castle, where they remained until the end of November and where their son the future Edward III was born on 13 November.
Finally, a treaty was made and sealed in London on 20 December 1312, in the presence of Cardinal Arnaud Nouvel, Arnaud d'Aux, bishop of Poitiers, Louis, count of Evreux, and the earls of Gloucester and Richmond.* Edward II was at Windsor at the time, with his queen and their baby son. It was agreed that the three earls and various barons would make obeisance to Edward II in his great hall at Westminster, "with great humility, on their knees" (oue graunte humilite as genuz/cum magna humilitate flexis genibus) and "humbly beg him to release them from his resentment and rancour, and receive them into his good will." The many precious goods belonging to Edward and Piers Gaveston which Thomas, earl of Lancaster had seized at Newcastle the previous May would be returned to Edward on 13 January 1313 (though in fact he didn't receive them until 23 February). On 16 December, four days before the treaty, Edward had granted Lancaster a safe-conduct and permission to use an escort of forty men-at-arms to bring him his possessions. (Patent Rolls, p. 517) It was specified that if any of Edward's many dozens of horses which Lancaster had taken were dead (si ascuns des chivaux soit mort), Lancaster would reimburse him with the price and value of the dead horses instead. No action would be taken against Piers' followers, and the three earls and all their own followers would be pardoned for anything they had done to Piers.
On 16 October 1313 at Westminster, Edward II pardoned the three earls, and more than 350 of their adherents, "of all causes of rancour, anger, distress, actions, obligations, quarrels and accusations, arisen in any manner on account of Piers Gaveston, from the time of our marriage with our dear companion, our very dear lady, Lady Isabella queen of England." The king had all his sheriffs proclaim the news throughout their counties. (Patent Rolls 1313-1317, pp. 21-26, 35-36; Foedera 1307-1327, pp. 230-233) Edward told the earls of Lancaster, Warwick and Hereford to "lay aside all suspicion, and...to come to his presence, and freely obtain the goodwill that they had so often sought." He watched them kneel to him, raised them and kissed them one by one, and absolved them; to mark their reconciliation, he also invited them to a banquet, and the following day they reciprocated. (Vita, pp. 43-44; Chronicle of Lanercost 1272-1346, ed. Herbert Maxwell, p. 203)
And this may have seemed the end of it, but of course it wasn't. Edward's hatred for his cousin Thomas of Lancaster endured and his desire for revenge never left him; on 22 March 1322, he finally had Lancaster executed in a parody of Piers Gaveston's own execution.
* The text is printed in French in Foedera 1307-1327, pp. 191-192 and Annales Londonienses 1195-1330, in W. Stubbs, ed.,Chronicles of the Reigns of Edward I and Edward II, vol. 1, pp. 221-225. A text in Latin appears in R. A. Roberts, Edward II, the Lords Ordainers and Piers Gaveston's Jewels and Horses (1312-1313) (London: Camden Miscellany, xv, 1929), pp. 17-21.