The place where the plaintiff’s railroad crosses Cambridge Street is subjected by law to two coexistent uses. It is at once a public way and a railroad location. Because it is the latter the plaintiff has the right to construct, maintain, repair and operate there its railroad and such structures and apparatus as it is required to have there for the proper prosecution *250of its work as a common carrier by means of steam cars. Because the land is a public way the city also has some duties and rights with reference to the same territory, arising from its obligation to keep the public ways within its limits reasonably safe and convenient for ordinary travel.
The present controversy arises from a contention on the part of the city that its own rights and duties with reference to the land are paramount and superior to those of the plaintiff, and that the latter cannot dig up the surface of the land to repair structures and apparatus which it must there maintain and operate except by the permission of and under the control and authority of the city. In accordance with this contention the officers and agents of the city, by verbal prohibitions and the actual display of physical force and threats, have prevented the plaintiff from opening the surface of the land within the railroad location in order to repair certain gates which the plaintiff is there required to maintain and operate as a means of securing the safety of travellers. The powers and rights now in question are purely statutory, and unaffected by the fact that the plaintiff’s lessor has title in fee to part of the land.
The relative rights and duties of railroad corporations and of municipalities charged with the care of public ways crossed at the same level by railroads, with respect to the territory included at the same time within the railroad location and the limits of the way have often been before the courts for adjudication. In Lowell v. Boston & Lowell Railroad, 23 Pick. 24, 30, it was held that a railroad company undoubtedly had a right to make excavations in a highway for the purpose of constructing its railroad, and that the company was not bound to erect barriers across the way if it had given seasonable notice of its intended operations to the officers of the town, and that after barriers were erected the Company might take them down from time to time if necessary for removing rocks and rubbish which could not be removed otherwise.
In Jones v. Waltham, 4 Cush. 299, a deep pit unrailed had been constructed by the railroad company for a cattle guard next to the line of the highway, and it was held that if the town had made the crossing safe and convenient except so far as the construction and operation of the railroad rendered it im*251practicable to do so without interfering with the railroad the town was not liable. See Davis v. Leominster, 1 Allen, 182, 184. The same principle was applied in Vinal v. Dorchester, 7 Gray, 421, where the injury was occasioned by the actual running of a train across the highway at a level crossing. In that case it was said, “Towns . . . can neither enlarge nor diminish the powers and privileges, or the duties and responsibilities of railroad corporations.” So in Noyes v. Gardner, 147 Mass. 505, 509, it is held that the liability of a town is limited to the extent to which “the construction or operation of the railroad, deprives the town of the power to discharge the general statutory duty to which it is subjected.”
In Old Colony Railroad v. Fall River, 147 Mass. 455, 464, the general principle governing the municipality and the railroad corporation in the exercise of the powers and duties of both at crossings is held to be that the town and the railroad are each left to perform its own duty as it may, having regard to the rights of the other. So in Flanders v. Norwood, 141 Mass. 17, 19, it was said, “ Railroads and highways are equally parts of the system which provides for the public travel. When they cross each other, and thus jointly use the same ground, it is necessary that reasonable rules should be adopted to reconcile this joint use.” In that case a bridge which carried the railroad across the way at. a level higher than the travelled path having been burned, the railroad company built a temporary bridge supported by timbers and trestle work which obstructed travel on the highway. It was held that it was not the right and duty of the officers of the town tp remove these supports, and that it was the right and duty of the railroad to rebuild its bridge even if it would be impossible to do this without obstructing the highway to some extent.
In Commonwealth v. Hartford & New Haven Railroad, 14 Gray, 379, the railroad at a level crossing having been constructed with but a single track, it was held that the company might put down and maintain within its location the number of tracks essential for the convenient transaction of its business, and for that purpose make any necessary alteration in the grade or surface of the highway there.
So, in the moving of trains “ Railroads, from the necessity of *252the case, have the right to the exclusive use of grade crossings when their trains are passing.” Granger v. Boston & Albany Railroad, 146 Mass. 276, 280. Marden v. Boston & Albany Railroad, 159 Mass. 393, 396. The right to this exclusive use extends to the switching of cars and the making up of trains when done only to a reasonable extent and in a reasonable manner. Gahagan v. Boston & Lowell Railroad, 1 Allen, 187.
The tracks of a railroad are supported and kept in place by ties imbedded in the ground beneath its surface. The planking laid on each side of and between the rails to facilitate passage across them, and the rails themselves are parts of the surface of the highway at a level crossing. It may be necessary at any moment for the railroad company to disturb these parts of the surface of a street at a level crossing to make repairs absolutely essential to the operation of the railroad. Anything which imposes upon the company delay in the making of such repairs, or makes their right to proceed with them contingent upon obtaining permission from some independent repository of power, is a menace to the safety of the public. Besides this there were at the Cambridge Street crossing gates which the plaintiff was required by law to maintain and operate, which were out of repair, and which were so constructed as to make it necessary to dig up the surface of the street in order to repair them so as to operate them as required by law.
The actual conflict between the plaintiff’s workmen and the defendant’s policemen came in consequence of the defendant’s contention that the plaintiff before proceeding to dig up the street within its own location must apply for a license from the city officials and give a bond to the city under certain city ordinances. These ordinances were not drawn with special reference to the opening up of the surface of streets by railroad companies at crossings. They rest on no legislative authority except the general power given to municipalities to make bylaws and ordinances not inconsistent with law. Neither St. 1853, c. 151, § 1, nor the statutes constituting the charter of the city give it any right to make ordinances which shall restrict the power of the plaintiff to construct, repair and operate its railroad. The power given in St. 1853, c. 151, § 1, to determine in what manner the railroad shall be constructed across the streets *253within the city of Cambridge and what securities shall be provided and maintained by the railroad company at such crossings is of the special class mentioned in Vinal v. Dorchester, ubi supra, and in its exercise the officers of the city do not act under its authority nor as its agents, or by force of its ordinances. The ordinances are adopted alio intuitu and cannot be justified in their present form under that statute, if construed to apply to territory included within the limits of the location of a steam railroad.
The defendant’s ordinances forbid the digging up the ground in any street, or otherwise occupying, encumbering or obstructing the street without first obtaining a written license from the superintendent of streets, and complying in all respects with the conditions of such license. If construed to apply to railroad corporations at street crossings, as every passing locomotive or car occupies and obstructs the street, the ordinance would require a written license from the superintendent of streets for the passage of every train. The ordinance requires the party licensed to fence the excavation or obstruction and to light it at night. It authorizes the superintendent of streets to prescribe a time within which the street shall be restored to good condition, and requires the license to be delivered up to him on or before the expiration of the time so limited, and requires the licensee to pay whatever sum the superintendent may expend for putting the street into good condition, thus impliedly giving him authority to interfere with or himself undertake the construction of the railroad and its appliances at the crossing, if the ordinance is applicable. It further gives the superintendent power for one year after any portion of a street has been excavated to make forthwith such repairs as the superintendent deems necessary, and in case of failure to comply with such an order gives the superintendent the right to make them at the expense of the licensee. If construed to apply to railroads the statutory right of the railroad company to construct, maintain, repair and operate its own railroad can be exercised only upon consent of the superintendent of streets and only in the manner stated in his license, and for a year thereafter he has authority to enter upon and alter as he deems necessary the surface of the railroad at the crossing. The ordinance forbids him to issue any license to a person who *254■within a year has failed to comply with the terms of a license. The license may be revoked at any time, and it cannot be obtained except by giving a bond to indemnify the city from all liabilities, loss and expense which the city may incur.
It is obvious that if the ordinance is to be construed to apply to railroad corporations in the exercise of their rights at grade crossings it prevents the exercise of those rights in every instance until after a delay which is equivalent to a denial of the right and which may in the meantime subject the public to danger and the railroad corporation to liability and expense not contemplated by law. Besides this it attaches to the exercise of the right of the railroad corporation to keep its own roadbed and tracks in repair and to operate its railroad requirements on the part of the city which both diminish the powers and privileges and enlarge the duties and responsibilities of the company contrary to the rule stated in Vinal v. Dorchester, ubi supra, and to the theory of the statutes defining the obligation and rights of municipalities and of railroad corporations.
If the defendant’s ordinance were to be construed literally and as applying to the operations of railroad companies within the limits of their own locations it would be void as contrary to law. But similar ordinances and by-laws are in existence in many places, and it never has been contended that they should be construed to apply to railroad companies as to operations within the limits of their own locations. We are of opinion that the defendant’s ordinance was not intended to and ought not to be construed to have application to the operations of railroad corporations at places where their railroads cross public ways, and that the whole position of- the city authorities which has given rise to the present controversy is unsound and untenable.
As the defendant has placed its defence upon its incorrect construction of the relative rights and obligations of the parties to the suit, rather than on the question whether the bill is an appropriate method of bringing the controversy here for determination, it is not necessary to discuss that question. .
Decree to be entered for the plaintiff.