The announcement came from Interior Minister Fernando Grande-Marlaska on Monday afternoon as the number of deaths in Spain from COVID-19 soared to over 300.
Only Spanish residents returning to their home in Spain or those with authorization would be allowed to cross into Spain, he said, adding that documents would be required to show valid reason for entering.
The closure, which will affect all cross-border traffic with France, Portugal, Andorra and Gibraltar, was to remain in place until the end of an alert that began on Saturday for an initial period of two weeks although it could be extended with the permission of Spain’s parliament.
The measure will not affect the transportation of goods, the interior minister pointed out.
Spain has not yet closed air traffic to and from its airports but the interior minister did not rule it out as a step to be taken in the future.
The move came after Spain imposed a string of unprecedented restrictions, ordering its 46 million population to stay home, shuttering everything except food shops, chemists and petrol stations.
But by 2:30 pm (1330 GMT) on Monday, the health ministry had counted 9,191 cases and 309 deaths, prompting the government to announce the closure of its land borders.
The virus has spread like wildfire across Spain, making it the second worst-hit country in Europe after Italy.
- MAP: The regions of Spain most affected by coronavirus outbreak
- Coronavirus lockdown: What to do if you are on holiday in Spain
- Coronavirus: What you can and can’t do during Spain’s lockdown
Despite Monday's figures, the increase was lower than the weekend numbers when 2,000 infections were detected between Saturday and Sunday and the number of deaths rose by around 100.
Of the total number, Madrid remains the worst-affected region, with 4,165 cases.
In the worst-case scenario, infections were likely to “continue rising for at least another 10 days,” said Fernando Simon, the health ministry's emergencies coordinator.
In the alert declared on Saturday aimed at curbing the number of infections, the government ordered every household to remain in complete isolation and people have been allowed out only to buy food and medication, or
to go to hospital.
Everything else has been closed down, with the exception of public transport, which was running a somewhat reduced service to allow those working in essential jobs to get around.
Despite the unprecedented closure, some metro lines and interurban trains were packed to capacity on Monday morning, with travellers forced to squash in at close quarters, media images showed.
Transport Minister Jose Luis Abalos warned that the state of alert, which was initially put in place for a two-week period, would almost certainly be extended in a move which would need the approval of parliament.
“It's clear that we will need to extend this situation… I think it's clear that 15 days won't be enough to win the battle,” he told RNE, Spain's public radio.
So far, troops have been deployed in 14 cities to help efforts to disinfect the streets or ensure compliance with the restrictions on movement.
Spain's benchmark Ibex-35 tumbled more than 9.0 percent on Monday, mirroring falls in stock markets across the globe, with the restrictions keenly felt in the car industry which represents nearly 10 percent of Spain's gross domestic product (GDP).
Supply problems caused by the crisis have forced Renault, Seat and Nissan to suspend all activity in Spain, Europe's second car manufacturer after Germany.
And PSA, which owns the Peugeot and Citroen brands, also said it was halting production in Spain and across the rest of Europe.
The lockdown also forced the cancellation of regional elections in the northern regions of Galicia and the Basque Country, local officials said.