The Torah in Parashat Shoftim (Debarim 16:21) commands, “You shall not plant an Ashera or any tree next to the altar of Hashem your G-d, which you will make for yourself.” This establishes a prohibition against planting a tree in the area of the Bet Ha’mikdash.
The Rambam explains that the idolaters would adorn their temples with trees, and therefore, in order to distance us as much as possible from idolatrous practices, the Torah forbids us from planting trees in our Temple. The Torah wants us to avoid any possible connection or association with idol worship, and so it forbids practices which resemble pagan customs, including the planting of trees in the Bet Ha’mikdash.
Although the verse speaks specifically of planting a tree next to the altar, the Sages understood that the Torah forbids planting a tree anywhere in the Azara (courtyard of the Bet Ha’mikdash).
This prohibition includes all kinds of trees – both fruit-bearing trees, and tree which do not produce fruit.
The Sages enacted a prohibition against constructing wooden balconies in the Azara, as wood is made from trees, and thus building these structures in the Azara might lead to planting trees there.
This prohibition is binding upon both men and women. Even nowadays, one who plants a tree in the area where the Azara was situated transgresses this Biblical command.
There is some discussion among the Poskim regarding the permissibility of adorning the synagogue with trees. There is a well-known custom to adorn the synagogue with greenery on Shabuot, to commemorate the greenery with which G-d adorned Mount Sinai at the time of Matan Torah. But the Magen Abraham (Rav Abraham Gombiner, Poland, 1633-1683) mentions that some had the custom to bring trees into the synagogue for Shabuot, to commemorate the Bikkurim – first fruits – which were brought to the Bet Ha’mikdash on this day. The Gaon of Vilna (1720-1797) opposed this practice, as it resembled the custom to bring trees into churches. Hacham Ovadia Yosef, by contrast, defended this practice, explaining that this is allowed because it is done for a clear reason – to commemorate the Bikkurim. Imitating a gentile custom is forbidden when there is no other reason for the practice. In this instance, however, the trees are brought into the synagogue for a reasonable religious purpose, and so it is permissible.

