Located at the mouth of the River Tiber, Ostia was said to have been founded by Ancus Marcius, one of the kings of Rome, in the 7th century BC. However the most ancient archaeological remains so far discovered, are no earlier than the 4th century BC, and the most ancient buildings currently visible are from the 3rd century BC, notably the Castrum (military camp) and, of a slightly later date, the Capitolium (temple of Jupiter, Juno and Minerva).
Although Ostia was probably founded for the sole purpose of military defence -- since through the Tiber's mouths armies could eventually reach Rome by water -- in time the port became a commercial harbour, and a very important one too. Many of the goods that Rome received from its colonias and provinces passed through Ostia. In this role, Ostia soon replaced Pozzuoli (Puteoli, near Naples).
In 87 BC, the town was razed by Marius, and again in 67 BC it was sacked by pirates. After this second attack, the town was re-built and provided with protective walls by Cicero. The town was then further developed during the 1st century AD, mainly under the influence of Tiberius, who ordered the building of the first Forum. The town was also soon enriched by the construction of a new harbour on the northern mouths of the Tiber (which reaches the sea with a larger mouth in Ostia, Fiumara Grande, and a narrower one near to the current Fiumicino international airport). The new harbour, not surprisingly called Portus, was excavated from the ground at the orders of the emperor Claudius.
The town was provided with all the services a town of the time could require; in particular, a famous lighthouse. Archaeologists also discovered the public latrinas, organised for collective use as a series of seats that lets us imagine today that the function was also a social moment  .
Trajan too, required a widening of the naval areas, and ordered the building of another harbour, again pointing towards the north. It must be remembered that at a relatively short distance, there was also the harbour of Civitavecchia (Centum Cellae), and Rome was starting to have a significant number of harbours, the most important remaining Portus.
Ostia grew to 40,000 inhabitants in the 2nd century AD and in time focused its naval activities on Portus. With the end of the Roman Empire, Ostia fell slowly into decay, and was finally abandoned in the 9th century due to repeated invasions and sackings by Arab pirates; the inhabitants moved to Grigoriopolis .
A "local sacking" was carried out by baroque architects, who used the remains as a sort of marble store for the palazzi they were building in Rome. Soon after, foreign explorers came in search of ancient statues and objects. The Papacy started organising its own investigations with Pope Pius VII and the research still continues today. It has been estimated that two thirds of the ancient town have currently been found.
Ostia lived a new life during fascism, when it was renamed Lido di Ostia, or Ostia Lido, or Lido di Roma (Lido meaning beach): following the general urbanistic re-planning of Rome, a new quartiere was created ex novo in the southern side of the capital city (EUR), and a comfortable road was built to connect it with the seaside (dedicated to Christopher Columbus). Ostia became the beach resort of Rome, and was connected by a railway, while the first projects for the Fiumicino airport were drafted out. The town was re-organised in a pure so-called "fascist architecture " (which recalls some colonial, Mediterranean and rationalist styles) and divided into a coastal side, distributed in small villas used as second houses by Romans, and a rear side for workers (peripheral quartieri and borgate were created all around Rome for the lower classes, and Ostia was one of them).
However the fascist renewal was not long enjoyed by Romans, due to the imminence of World War II which arrived when part of the works were still in progress; it was only in the 1960s that Ostia began to be used as a beach and as a holiday site, effectively becoming a part of the town, and it still is part of the territory of the council of Rome.