In a republic, instead of voting directly about what they want to do, as in a democracy, people instead vote for people to represent them. Then those people decide what to do.
The world’s first republic may have been Carthage, in North Africa. Carthage started out with two kings who were elected by the senate. The Carthaginian senate had several hundred members who served their whole lives. They chose the Senators from among the rich men. But the government slowly changed. The Senate started to choose generals as well as kings. They wanted to separate running the army from running the country. Possibly, like Athens at the same time, Carthage had tyrants in the 600s BC. At some unknown time, shopfets, elected by the people every year, replaced the kings and ran the city. These shopfets were also usually rich men from old families. Eventually people also voted on who the generals should be. There was also a separate group of 104 judges who watched over the generals and shopfets to keep them honest.
About the same time, Roman government also turned into a republic. The Romans may have gotten the idea from Carthage (Carthage was more powerful at the time, so the reverse seems unlikely). The Roman Republic got started about 509 BC, just about the same time as the first democracy in Athens. The rules about who could vote were about the same as in Athens too. Slaves couldn’t vote, and neither could women, or children, or men who were not citizens. In addition, in Rome you could only vote if you owned land. So a lot of poor men could not vote at all even though they were free citizens (We don’t know if this was true in Carthage, but it probably was).
Like the Carthaginians, the Romans elected two consuls every year from among the patricians (the rich men). But under the Roman system, the consuls were also the generals. The Romans also elected other men to do less important jobs as tribunes, quaestors (KWEE-stores), and praetors (PRY-tores). (Only people who could vote could be elected, so only free men who were citizens and owned land could run for office).
Republics were more efficient than democracies, because most men who could vote only needed to vote in the big elections, and the rest of the time they could be at work. Only the Senators, the elected representatives, had to be voting all the time.
But the aristocrats (the rich people) of Rome and Carthage fixed it so that it was pretty much impossible to elect anyone who wasn’t already an aristocrat to the senate or to be a consul or a tribune or anything. So these republics were a lot like an oligarchy in that they tended to be run by rich people.
After the Romans destroyed Carthage in 146 BC, and the Roman republic collapsed about 30 BC, there was not another republic anywhere for about a thousand years. Then in the Middle Ages, around 1100 AD, there began to be small republics in various northern Italian cities like Florence, Siena, Pisa, Genoa, Venice, and Milan. Sometimes these cities joined together into the Lombard League, but often they acted independently. Like the Roman and Carthaginian republics, however, almost all the power still was in the hands of rich people, so that these republics were a lot like oligarchies.