Cities of the second class and villages shall have power to grant a franchise, subject to the conditions of this section and section 17-528.03, for a period not exceeding twenty-five years to any person, company, or association, whether publicly or privately owned, and to his, her, or its assigns, to lay and maintain gas mains, pipes, service, and all other necessary structures in the streets, lanes, alleys, and public places of such city or village for the purpose of transporting gas on, under, or along any streets, lanes, alleys, and public places of such city or village and for furnishing gas to the inhabitants of such city or village. The city or village may make any reasonable regulation with reference to any person, firm, or corporation holding such franchise as to charges for such gas. Such city or village is authorized to contract, lease, or rent the gas plant from any person, firm, or corporation furnishing gas within such city or village. Such contract, lease, or rental agreement shall not be for a period longer than five years. Such city or village may levy a tax to pay the rent under such lease or to pay for any gas used for street lighting or for other necessary purposes.