Police Scotland will take over railway policing when the function is devolved, Scotland's justice secretary has decided.
The move means that the British Transport Police (BTP) will no longer operate as a separate force in Scotland.
BTP wanted to continue providing this service, with oversight by Holyrood instead of Westminster.
But Justice Secretary Michael Matheson has decided against that.
He wants the force's Scottish operations and more than 200 officers integrated into Police Scotland.
In a statement, the Scottish government said: "Police Scotland is responsible for all policing in Scotland outwith the railways and we believe the functions of the British Transport Police should be integrated within the single service.
"The BTP provide a specialist function that is recognised and valued by the rail industry and its passengers and it is essential that this specialism is maintained within Police Scotland.
"This will ensure the most efficient and effective delivery of all policing in Scotland, keeping communities safe and strong".
Letter reveals 2011 takeover move
A letter released to the BBC by the Scottish government under freedom of information reveals that former Justice Secretary Kenny MacAskill offered to takeover the BTP in 2011.
He wrote to the then UK Transport Secretary Philip Hammond on the day that the creation of a single Scottish police force was announced.
In the letter, Mr MacAskill wrote: "I would like to explore the potential for the BTP in Scotland to become part of the new Scottish policing landscape".
The Scottish government has also released an email from the British Transport Police Federation, which represents police officers, expressing anger at the Smith commission recommendation.
In this note dated 5 December 2014, the federation's chairman, George Lewis said: "Such a move is both unjustified and unjustifiable.
"It is a betrayal of the BTP and our members who have worked tirelessly to achieve their policing targets year after year".
SNP ministers had a high-profile dispute with the British Transport Police over its use of stop and search when they first took office.
Mr Matheson told the Police Oracle website that railway policing needed to become part of Police Scotland because of the country's "distinctive approach to policing".
And he told BBC Radio's Good Morning Scotland programme: "Police reforms have been taking place in Scotland over the last 18 months, moving to the single force.
"It's been the Scottish government's view that this [transport policing] would be better if it was integrated into Police Scotland given that it would sit alongside our national police service.
"That's why we believe this would be a better fit for how we are taking policing forward in Scotland."
The Smith Commission on further devolution recommended that policing the railway be devolved and this was included in draft legislation drawn up by the UK government.
This is expected to become law after the general election and the BTP could become part of Police Scotland by the end of 2016.
A BTP spokesman said: "We are aware of the justice secretary's public comments on the future of railway policing in Scotland.
"Our number one priority remains the continued safety and security of the railways in Scotland, and across the rest of the network.
"Since the announcement that rail policing was to be devolved, we have been in dialogue with the Scottish and UK governments, the rail industry and other key stakeholders. These discussions continue."
A UK Department for Transport spokesman said: "How rail transport is policed in Scotland will be a matter for Scotland once the legislation is passed."
Labour MP Tom Harris was the minister responsible for the British Transport Police in 2007-08.
"BTP is a long-standing and effective police force" he said.
"It will be sad to see it merged with Police Scotland as part of a further centralisation of services.
"This move is premature. No-one has been consulted - neither the travelling public nor the police officers themselves. A hasty decision today could put at jeopardy the safety of the travelling public tomorrow."
Scottish Liberal Democrat leader Willie Rennie said: "Some people have argued that the Scottish Parliament should choose to keep the force as one single entity across the UK instead of integrating into Police Scotland.
"I think that is worthy of consideration. We need to have that debate. We need to consider this carefully rather than deciding now what the structure should be."
Scottish Conservative transport spokesman Alex Johnstone said: "People will look at this move and think the SNP is again using Police Scotland to make a political point.
"The British Transport Police are hugely respected and valued by passengers. One of their key duties is policing cross-border services, but now they will have to get off the train before Scotland and be replaced by officers from the single force.
Mr Johnstone added: "I think the public will be concerned by yet more centralising by the Scottish government."
BTP has 231 officers in Scotland according to the BTP federation website and a network of 11 offices within major railway stations.
It is dwarfed by Police Scotland which is the largest force in the UK outside London, with more than 17,000 officers.
Under one possible model, BTP could become the Scottish Transport Police division of Police Scotland.
The Scottish Police Authority, which oversees the work of Police Scotland, said it had already started discussions with the BTP.
BTP and its governing body are due to meet to consider their response to the Scottish government's plan.
The cross-border force is worried that losing its Scottish division could lead to the break-up of the entire force.
There have been previous discussions about the Metropolitan Police taking over railway policing in London.
BTP is not the only police force operating in Scotland alongside Police Scotland.
The MoD police and the Civil Nuclear Constabulary will continue to protect key sites.