The draft bill published on Thursday said the price cap would initially last until 2020, with the potential to be extended by up to three years if needed.
"The bill would require Ofgem to consult and impose the cap as soon as practicable after the legislation is passed", a government statement said.
Business and energy secretary Greg Clark adds: "People who show loyalty to well-known brands are paying hundreds of pounds a year too much on standard variable tariffs and I am determined that this practice should end".
Prime Minister Theresa May first proposed a price cap on the energy sector earlier this year, the biggest market intervention since its privatization nearly 30 years ago.
The government has yet to clarify whether the cap will be an absolute cap - meaning consumers can not be charged more than a set amount - or a relative cap, whereby the standard variable tariff must not be more expensive relative to fixed tariffs.
A pledge to change the law was included in the Conservative manifesto before June's General Election, but was dropped from the subsequent Queen's Speech after some Tory MPs claimed it was state intervention and anti-free market.
Ofgem said the extension of its prepayment safeguard tariff will save the households around £120 a year on average.
The energy regulator Ofgem has announced it will extend its price cap to one million more vulnerable households this winter.
The prime minister said that the draft bill was a vital step towards fixing the "broken energy market" and "offering crucial peace..."
The Competition and Markets Authority (CMA) found that customers of the Big Six energy suppliers on standard variable and default tariffs are paying £1.4 billion a year more than they need to.
She said: "Due to the Government's dithering, the four million households in fuel poverty - nearly one million of which includes a disabled person - will face another winter of cold homes and astronomical bills".
Rebecca Long-Bailey, Labour's shadow business secretary, said legislation must force the regulator to implement a price cap.
Around two-thirds of all energy customers in the United Kingdom are now on these variable tariffs.
British Gas owner Centrica and fellow "big six" supplier SSE saw their share values come under further pressure.
Until then a more limited price cap will cover another one million low income households, the regulator said.
What is a standard variable tariff?
Michael Lewis, chief executive of E.ON UK, said: "A price cap will not be good for customers; it will reduce engagement, dampen competition and innovation". That is why we are taking action to make that happen for our customers.
Ofgem had already proposed intervening in the part of the market that supplies more vulnerable customers.