The measure is expected to apply to 26 EU states as well as Iceland, Liechtenstein, Norway and Switzerland. UK citizens will be unaffected.
The ban came as deaths continued to soar in Italy and Spain, and France began a strict lockdown.
Europe has been badly hit by the virus, which has killed 7,500 globally.
Meanwhile, the Euro 2020 football competition has been postponed by a year.
The virus has infected more than 185,000 people worldwide, according to the World Health Organization.
What are the EU measures?
The travel ban will affect all non-EU nationals from visiting the bloc, except long-term residents, family members of EU nationals and diplomats, cross-border and healthcare workers, and people transporting goods.
Free travel is a cherished principle within the European border-free Schengen area. But in recent days many countries have unilaterally imposed full or partial border shutdowns in a bid to stop the spread of the coronavirus.
This prompted the commission to propose that the bloc act in a more unified fashion and restrict entry to the union as a whole, at the urging of French President Emmanuel Macron.
The measures were agreed in a video-summit between EU leaders on Tuesday afternoon and will now have to be implemented by member states.
"They said they will immediately do that," said EU Commission chief Ursula von der Leyen at a press conference. "This is good, so that we have a unanimous and united approach [where] the external borders are concerned."
The UK and the Republic of Ireland - which is part of the EU but not Schengen - will be invited to join the measure.
It was also crucial that the EU "unblocks the situation" with regards to closed internal borders, Mrs Von der Leyen said, because "too many people are stranded".
What are the latest updates in Europe?
In France, citizens who leave home must now carry a document detailing the reasons why, with fines for transgressors to be set at €135 ($150; £123).
It comes after President Macron put the country on a war-footing, ordering the population to stay at home and only go out for essential trips.
The number of confirmed cases in France grew by more than 16% on Tuesday, reaching 7,730, The death toll rose to 175, with 7% of the dead aged under 65.
More than 2,500 people are being treated in hospital, including 699 in intensive care.
In Britain, where the death toll is 71, people have been told to avoid social contact, work from home if they can and avoid all non-essential foreign travel.
The chancellor, Rishi Sunak, has unveiled a financial package worth £330bn ($400bn) to ease the burden caused by the virus, after Prime Minister Boris Johnson on Monday urged people to avoid pubs, clubs and cafes.
Meanwhile, the government's chief scientific adviser said it would be a "good outcome" if 20,000 or fewer people died of the virus in the UK.
The latest set of Brexit talks has also been delayed.
The number of confirmed cases in Spain has soared by 2,000 to 11,178. Authorities there are maintaining a partial lockdown on 47 million people.
It is now the European country worst-affected after Italy.
At midnight Spain began stopping cars crossing its borders from France and Portugal. Only Spanish nationals, residents and cross-border workers were being allowed to the country.
Italy, which has registered the most cases outside China at more than 31,500, announced another surge in deaths on Tuesday, from 2,150 to 2,503. The country remains in lockdown.
The government meanwhile is set to renationalise flag carrier airline Alitalia with a rescue package worth $670m (£550m).
Germany, which has had more than 6,000 cases and 13 deaths, banned religious services and told people to cancel any domestic or foreign holiday travel.
Venues including clubs, bars, leisure facilities, zoos and playgrounds will be closed. Schools are already shut.
Ireland could have 15,000 cases of coronavirus before the end of March, saidPM Leo Varadkar. In a St Patrick's Day address, he warned of "significant and lasting" economic damage, and said the emergency could last into the summer. The government has already closed pubs, schools and universities.
Elsewhere in Europe:
- Belgium's death toll doubled from five to 10 on on Tuesday
- Sweden is to close all high schools and universities from Wednesday
- Orthodox priests in Georgia have started blessing the streets of the capital Tbilisi with holy water
What is the latest elsewhere?
Iran remains the world's third-worst-affected nation, after China and Italy.
More than 16,000 people are confirmed as infected and 988 have died, although some analysts believe the figures are far higher than officially reported.
A spokesman for the judiciary said on Tuesday that 85,000 prisoners, including political prisoners, had been temporarily released to try to combat the spread.
Gholamhossein Esmaili did not say when or how those freed would be returned to prison, but stressed that only prisoners serving five years or less had been released.
Most shops and restaurants remain open but the health ministry has urged people to stay at home.
In the US, the White House is working on a economic stimulus package reported to be worth some $850bn, with Treasury Secretary Steve Mnuchin saying the administration was "looking at sending cheques to Americans immediately".
The total number of cases has risen to above 4,200, with 75 deaths, said the US Centers for Disease Control and Prevention. Most cases are in the states of New York (669), Washington (708) and California (369),
The pandemic has disrupted the Democratic primary election season.
In other developments:
- China reported just one new domestic infection on Tuesday - but 20 more from people arriving from abroad. It also said it "strongly opposed" Mr Trump's reference in a tweet to the "Chinese virus"
- The Philippines became the first nation to shut its stock exchange indefinitely
- Malaysia is barring people crossing the border with Singapore from Wednesday, sparking a rush on food stores in the city state, which depends on Malaysia for supplies
- India's iconic Taj Mahal monument has shut down
- Scientists in Australia say they have identified how the body's immune system fights the Covid-19 virus
BBC