Sintra is 40 minutes from Lisbon by train on the Sintra Line, which runs from Lisbon's Rossio station. Trains run frequently throughout the day; buy tickets from machines at any station or use a Viva Viagem card. The railway station at Sintra is itself a beautiful 19th-century building worth a look.
By car, the A37 motorway runs from Lisbon and takes about 30 minutes outside rush hour. Driving to Sintra is possible but parking near the monuments is limited and expensive; leaving the car at the station and taking the bus up to the palaces is a better option. Day tours from Lisbon are widely available if you prefer a guided visit; they typically combine Sintra with Cabo da Roca and Cascais.