Who wrote Megilas Esther?
At first glance the answer seems obvious, Mordechai as it says in the Megilla. In fact Rashi comments on the pasuk, ויכתוב מרדכי - that Mordechai wrote the Megilla as we have it. However, the Gemara in Bava Basra seems to contradict this. The Gemara there details who wrote each one of the 24 sefarim of Tanach. The Gemara says that the Anshei Knesset Hagedola wrote: Yechezkel, Trei Asar, Daniel, and Esther. Rashi explains that all of these happened in chutz laaretz and לא נתנה נבואה ליכתב בחוץ לארץ. Therefore the אנשי כנסת הגדולה wrote them later in Israel.
So who wrote Megilas Esther? Mordechai or the אנשי כנסת הגדולה? In truth, Mordechai was a member of the אנשי כנסת הגדולה however that doesn't help us for 2 reasons:
1. The אנשי כנסת הגדולה did not yet exist at the time of Purim, it was only created after the second beis hamikdash was built
2. Mordechai wrote the Megilla in Shushan and as Rashi explained נבואה cannot be written outside of Israel and the reason why the אנשי כנסת הגדולה wrote these seforim is specifically because the events occured in chu"l and they needed to be written in Israel.
The Brisker Rav has a fascinating answer. The Rambam in Hilchos Megilla leaves out certain dinim (עיבוד לשמה, the way to write the 10 sons of Haman, etc.). On the other hand, the Megilla has other dinim that are the same as a sefer torah. The Brisker Rav explains that there are 2 dinim of Megilla.
1. Megilla as a sefer/letter that was written by Mordechai right after Purim. This did not have the status of being part of Tanach. At that time the Chachamim created a chiyuv to read that sefer that Mordechai wrote
2. Megilla as part of Tanach.
Based on this he explains why the Rambam left out certain dinim and included certain dinim.
What comes out is that according to the Brisker Rav, Megillas Esther was written twice. The first time, in Shushan by Mordechai, it was not part of Tanach and had no kedusha. However, this is the sefer that we are chayav to read on Purim. Later in Israel the Anshei Knesset Hagedola rewrote the sefer and included it as part of Tanach.
What does it mean that the אנשי כנסת הגדולה wrote the sefer in Israel . The simple understanding of the Gemara in Bava Basra is that they actually rewrote the whole sefer ברוח הקדש as Rashi explicitly writes that they wrote the seforim in Israel. What is amazing is that the אנשי כנסת הגדולה wrote ברוח הקדש the exact same thing word for word as what Mordechai wrote in Shushan. The chiyuv to read the Megilla is what Mordechai wrote in Shushan and we only have 1 version.
To summarize, according to the Brisker Rav Megillas Esther was written twice. Firt it was written right after the events in Shushan by Moredechai. This sefer is what we are commanded to read on Purim. Years later, the אנשי כנסת הגדולה convened and rewrote the sefer ברוח הקדש and made it part of Tanach.