There are two categories that determine whether a visitor needs a visa for Mexico: free nationalities, which only need to fill in a form at the port of entry, and restricted nationalities, which need to obtain a visa before travelling to Mexico.
Citizens, permanent residents and holders of a multiple-stay visa for the USA, Canada, Japan, the UK or any of the Schengen countries can visit Mexico without a visa. Foreign nationals that do require a visa to visit Mexico should apply at their nearest Mexican consulate before arriving in the country. Visitors can remain in Mexico for up to 180 days.