A consulate is an official office of a country in another country, whose purpose it to provide specific services to its citizens who happen to be in that country, and to provide services to others in that country who may want to visit or do business in or with the home nation.
A consulate can handle lots of different kinds of business, but it typically issues visas for those wishing to visit it's home nation, may provide passports to its own citizens in that country, ensures that if one if its citizens gets in legal trouble, they receive fair treatment, can help its citizens in certain emergencies. It may also handle public relations, host trade delegations, and provide a wide range of other services.
By contast an embassy is the representative of one country's government to another country's government. The Ambassador is in charge of the relationship between governments.