Virgin had been set to lose the West Coast franchise it has operated since 1997.
But the Government scrapped the bidding after Department for Transport (DfT) faults were found with the bidding process.
Today's temporary deal, announced by Transport Secretary Patrick McLoughlin, will see Virgin carry on with the London to Scotland route until November 9, 2014, after which the West Coast line will be let under a long-term franchise.
Mr McLoughlin said: "We are determined to ensure not only that passengers continue to experience the same levels of service they have in the past, but that services improve.
"There will be a new hourly service linking Glasgow and London and we will also work with Virgin Trains to explore other service improvements."
He went on: "I am also extremely pleased that passengers will benefit from up to 28,000 more seats daily thanks to the delivery of 106 new Pendolino carriages on to the West Coast line which has happened on budget and ahead of schedule."
The Government announced today that the DfT would be able to shorten the 23-month period "by up to six months if a subsequent franchise can be let on a shorter timescale".
Virgin had high hopes of extending its long tenure on West Coast when bids were invited for a new 13-year franchise which was due to start on December 9 this year.
But in August the DfT announced the new franchise had gone not to Virgin but to rival transport company FirstGroup.
It was only after Sir Richard, who had branded the bidding process "insane", mounted a legal challenge to the decision that Mr McLoughlin scrapped the bidding process, saying there had been mistakes by the DfT.
Three DfT officials were suspended and negotiations were started with a view to getting Virgin to run the line for between nine and 13 months before a short interim franchise was offered followed by a longer one later.
Today's news means the Government has altered its plans for the immediate future of the line, in that the Virgin temporary deal is for far longer and there will be no interim franchise before the long-term one is introduced.
When he pulled the plug on the West Coast franchise bidding, Mr McLoughlin appointed businessman Sam Laidlaw to produce an independent report into the fiasco.
After producing damning initial findings, which listed failings by the DfT, Mr Laidlaw presented his full report to the department last week.
But with one of the suspended department officials, Kate Mingay, mounting a legal challenge to her suspension, Mr McLoughlin announced that he was delaying the Laidlaw report publication until this week, with publication likely later today.
Mr Laidlaw had been due to appear before the House of Commons Transport Committee this week, but MPs will now hear his evidence on December 18.
The committee's chairman, Louise Ellman, criticised the DfT over the delay and the RMT transport union has been upset that the department did not take the opportunity to take the West Coast line into public ownership.
Transport company Stagecoach, which has a 49% stake in Virgin Rail, said that under the new agreement, Virgin will initially earn a fee equivalent to 1% of revenue with the DfT taking the risk that revenue and/or costs differ from those currently expected.
It added that Virgin and the DfT had agreed to seek to negotiate revised commercial terms that would see Virgin take greater revenue and cost risk for the period to November 2014 for a commensurate financial return.
Stagecoach finance director Martin Griffiths said: "This is a good deal for passengers and taxpayers, as well as our business and Virgin Trains' employees.
"It will ensure customers continue to benefit from the best customer service on the UK rail network and it brings continuity for our people. Our agreement also gives value for money to taxpayers and an appropriate return to the shareholders whose private investment underpins Britain's rail system."
He went on: "We now want to press ahead and develop the West Coast business further, maintaining the high quality of service and bringing more improvements to our customers.
"While this has been a difficult few months, we believe the future prospects for the West Coast franchise and the wider rail network are very positive."
Mr McLoughlin has ordered an independent inquiry into the franchise system, while halting existing bidding processes.
Mr Griffiths said today: "It is now crucially important that the rail franchise programme gets back on track on a sustainable basis as soon as possible.
"This will allow train operators to build on the already high quality of service to passengers and focus even more closely on ensuring the rail system delivers value for money."
Virgin Rail Group chief executive Tony Collins said: "I'm delighted that we have an agreement with the DfT that gives us the chance to continue providing high-quality services to our customers.
"We have had great support from staff and customers in recent months and we will repay that loyalty with even better service."
He went on: "We will not be sitting back in the coming months, but are keen to introduce more improvements to the service.
"We are proud of what we have achieved since 1997, but there is undoubtedly more to come and we will work closely with the DfT to bring even better services in future."
The RMT union had been hoping that due to the West Coast franchise fiasco, the DfT might approve overseeing the running of the line in the public sector, as is the case for the time being with the East Coast line.
Today, RMT general secretary Bob Crow said: "Richard Branson has muscled his way into a monopoly provider position on this main line route and has extracted a longer extension than expected, leaving it wide open to legal challenge.
"Meanwhile, pure right-wing ideology stopped this sub-Thatcherite Government from using the safe, efficient and cost-effective option of renationalising the West Coast."
The botched franchise process on West Coast is costing taxpayers at least £40 million - money which Mr Crow said could have been used to invest in services.
The cost to the public could rise should FirstGroup, whose shares dipped when the bidding was cancelled, seek damages.