Diesel trains currently operate on the Great Western Main Line
A £1bn plan to electrify the main rail route between London and Swansea has been announced by the government.
A second line between Liverpool and Manchester will also be converted from diesel to electric.
Ministers say electric trains are lighter and more energy efficient, cutting the running cost and environmental impact of train services.
The Conservatives welcomed the move but said the government was leaving the taxpayer to foot the bill.
Transport Secretary Lord Adonis told the BBC the massive investment involved would be worth it.
"With the electric trains you get a quieter, cleaner, more reliable and much cheaper train which benefits passengers and it also benefits the taxpayers because it's much cheaper to keep an electric railway going," he said.
Electric trains are quieter, cleaner, more reliable and cheaper, says Lord Adonis
"But you've got to put that upfront investment in. Governments historically have been very averse to making long-term investments.
"We've taken the decision that the right thing for the country is to have an electrified railway across the principal main lines and that's why we're going ahead with electrifying the Great Western Main Line."
He said the investment would pay for itself over a 40-year period and that there would be no impact on fares.
'Greener and cleaner'
Prime Minister Gordon Brown, at London's Paddington station for the announcement, said improving the rail network was important for the country.
"This is the future. It's greener, it's cleaner, it's faster, it's more reliable. It's making the railways fit for the 21st Century and encouraging more passengers to use the railways," he said.
The move means an electric version of the new Super Express intercity train unveiled last year will be introduced on the Great Western line.
The government and rail industry agree electrification will bring major benefits.
Electric trains do not carry their own fuel - weighing around six tonnes for a non-electric intercity train - and have lighter engines.
Network Rail will buy specialist electrification trains capable of automating the installation job.
The Campaign for Better Transport is concerned the investment will lead to an increase in fares but ministers say electrification will mean cost savings in the running of trains.
Shadow transport secretary Theresa Villiers said: "Yet again Labour are maxing out Network Rail's credit card, leaving the taxpayer to foot the bill.
"After [Business Secretary] Lord Mandelson announced cuts to the transport budget, how can we believe that Labour can announce £1.1bn of new spending without impacting on existing transport commitments or putting further strain on public finances already stretched to breaking point?"
Six tonnes of fuel and eight miles to the gallon: Why diesel trains are being consigned to history
Liberal Democrat transport spokesman Norman Baker said: "This must be just the start of the project. The Liberal Democrats want virtually the entire network electrified by 2040."
Plaid Cymru welcomed the electrification, and claimed it followed its pressure to change plans to electrify the track between London and Bristol only.
South West Wales AM Dai Lloyd said the change followed "an immense amount of work" by party leader Ieuan Wyn Jones, who is also transport minister in the Welsh Assembly Government.
The RMT rail union has called for "cast iron" assurances from the government that the decision will not hit jobs at the UK's only train manufacturer, Bombardier.
The Derby-based firm has bid for a contract to build 200 diesel trains, some planned to be used on the Great Western line, against rivals from Spain and China.
The union's general secretary, Bob Crow, said: "RMT welcomes today's announcement on electrification and is calling on the government to do some joined-up thinking and ensure that there is no risk at all to Bombardier from the expected cancellation of diesel orders.
"There is no reason why Bombardier can't produce rolling stock for the electrified lines as well as meeting demand from the overall expansion of rail services and the call to end overcrowding."
Britain went through a period of electrification between the 50s and 80s in which two other main lines, the East and West, were converted.
Many commuter lines into London from the home counties are also electrified, using a third rail system rather than overhead cables.
EUROPE'S ELECTRIC RAIL COVER
But Britain still has proportionally less electric railway than most European countries and is below Macedonia in the league table.
The announcement means Wales will have its first stretch of electrified railway.
Between Manchester and Liverpool a smaller project to electrify the line via Newton-le-Willows has also been given the green light.
This will have the added benefit of allowing Transpennine trains between Manchester airport and Glasgow to run on electric power.
The government is still considering electrifying another major diesel route, the Midland Main Line between London and Sheffield, but has not committed the proposal.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.