While visiting Portugal, my husband and I took one of the first trains out from Lisbon. Having arrived in Sintra around 7am Wednesday morning, we walked to town from the station and accomplished our goal of beating the crowds. Though the stores weren't open yet, we enjoyed having the quiet little square to ourselves. We patiently waited for the first bus which would take us up the hill to the Pena Palace. Unfortunately for us, the bus was not only late but it was also completely full! The second bus was the same - totally full! The reason for this is because it first stops at the train station, picking up loads of tourists before heading into town. We ended up hiring a tuk-tuk to take us up the hill, and by the time we got there the castle was swarmed with people. We had thankfully purchased our tickets online, as Rick suggests, so we were able to skip the ticket line. Once you get beyond the castle gates wander around its towers and outer walls, you will discover another line to get into the actual interior of the castle. It was so long, we ended up skipping it.
My recommendation for anyone trying to beat the crowds to the Pena Palace and the Moorish Castle is to go ahead and hire a taxi or a tuk-tuk BEFORE the buses begin running. A turk-tuk will cost you 5€ per person, but it's well worth the time it will save you.
(Note: the buses start running around 9am. The Palace opens at 9:30am)