The verse is Rigveda 3.62.10, from the third book, which tradition links with the sage Vishvamitra. It is addressed to Savitṛ, a Vedic god connected with the Sun and with stirring things into motion, which is why it is also called the Savitri. Gayatri is really the name of its metre: three lines of eight syllables each. The first line as preserved has only seven, and scholars restore the eighth by reading vareṇyam as vareṇiyam.
The opening 'Om bhur bhuvah svah' is recited before the verse and isn't part of the Rigvedic verse itself. It joined the verse through later ritual practice. The three words, called vyahritis, name three realms: earth, the space between, and heaven.
Its Sanskrit is roughly three thousand years old, and its meaning has long been discussed. We print it without the Vedic accent marks. The word dhīmahi, for example, is traditionally taken as 'we meditate', while some modern scholars read it as 'we receive' or 'we make our own'. It also has a harder history: for many centuries it was taught only through the sacred-thread ceremony, which excluded women and everyone outside the top three varnas. Many reformers and teachers have since opened it up, and people today hold different views on this.