King Salman's decree, which takes effect next June, is part of an ambitious reform push that runs the risk of a backlash from religious hardliners.
Saudi Arabia was the only country in the world to ban women driving, and it was seen globally as a symbol of repression in the Gulf kingdom.
US President Donald Trump welcomed the decision as "a positive step toward promoting the rights and opportunities of women in Saudi Arabia".
British Prime Minister Theresa May hailed it as an "important step towards gender equality".
Saudi Arabia will use the "preparatory period" until June to expand licensing facilities and develop the infrastructure to accommodate millions of new motorists, state media said.
Conservative clerics in Saudi Arabia, an absolute monarchy ruled according to Islamic sharia law, have long opposed lifting the ban, arguing it would lead to promiscuity.
One of them even claimed that driving harmed women's ovaries.
The announcement on Tuesday follows decades of resistance from female activists, many of whom were jailed for flouting the ban.
"A glorious day. Can't hold back my tears," tweeted Latifah Alshaalan, a member of the Shura Council, which advises the cabinet.
"Congratulations to the women of my homeland."
Activist Manal al-Sharif, who led the 2011 "Women2Drive" protest movement, tweeted: "Today, the last country on earth to allow women to drive... we did it."
- 'A new era' -
Human rights watchdog Amnesty International said: "It is a testimony to the bravery of women activists who have been campaigning for years that... Saudi Arabia has finally relented and decided to permit women to drive."
Saudi Arabia has some of the world's tightest restrictions on women.
Under the country's guardianship system, a male family member -- normally the father, husband or brother -- must grant permission for a woman's study, travel and other activities.
Signup to our newsletter and follow us on Facebook and Twitter!
It was unclear whether women would require their guardian's permission to apply for driving licences.
After Tuesday's announcement, the hashtags "I am my own guardian" and "Saudi Women Can Drive" gained traction on social media, while many openly lampooned conservatives who long defended the ban.
One Saudi woman tweeted a picture of three women in a convertible going shopping, with the message: "Us soon".
The policy could socially liberate women -- heavily reliant on foreign drivers and ride-sharing apps -- and also boost the economy at a time of low oil prices by increasing their participation in the workforce, analysts say.
"Putting women behind the wheel is the most effective way to announce to the world -- and to Saudis -- that the kingdom is entering a new era," Kristin Diwan, of the Arab Gulf States Institute in Washington, told AFP.
"The reign of puritanical Islam is over."
- 'Biggest PR win' -
There was some opposition online, however, with some men criticising the decision on Twitter under the slogan "the people refuse women driving".
"The Saudi people and especially the young people are not ready for this phenomenon and it will bring a lot of misfortune," one tweeted.
But most who used the negative hashtag were women mocking men opposed to them driving.
The announcement follows a dazzling gender-mixed celebration of Saudi National Day at the weekend, the first of its kind, which aimed to spotlight reforms.
Men and women danced in the streets to drums and electronic music, in scenes that were a stunning novelty in a country known for its tight gender segregation.
Women were also allowed into a sports stadium -- previously a male-only arena -- to watch a concert, a move that chimes with the Vision 2030 plan for social and economic reform.
With more than half the country aged under 25, Crown Prince Mohammed bin Salman, the king's son and the architect of the reforms, is seen as catering to the aspirations of youths.
"Allowing women to drive is the biggest PR win that Saudi Arabia -- and Prince Mohammed -- could have in a single swoop," said Jane Kinninmont, of London-based think tank Chatham House.
Already viewed as the de facto ruler controlling all the major levers of government, Prince Mohammed, 32, is seen as stamping out internal dissent before any formal transfer of power from his 81-year-old father.