The plaintiff and those under whom he claims have used a right of way “ openly, adversely, and uninterruptedly ” across the railroad of the defendant for more than twenty years prior to the acts of the defendant declared on. The most important question which the parties have presented is whether, under the statutes as they now exist, a private right of way by prescription can be acquired by an individual over the location of a railroad corporation. That such a right of way may be acquired by reservation, by grant, or by agreement of parties, is well established. Boston Gas Light Co. v. Old Colony & Newport Railway, 14 Allen, 444. Gay v. Boston & Albany Railroad, 141 Mass. 407. If such a right might be thus acquired, there would be nothing inconsistent in holding that it might be acquired by prescription, and that twenty years’ adverse user would be evidence of a grant thereof. In Fisher v. New York & New England Railroad, 135 Mass. 107, it was held that the St. of 1861, c. 100, (Pub. Sts. c. 112, § 215,) which in substance provides that no length of possession or occupancy of land of a railroad corporation by an abutter shall create a right in such land *436to the abutter, would not prevent him from acquiring a right to a private way across the railroad by a twenty years’ user thereof.
That which the defendant urges as the strongest argument against the plaintiff’s having acquired a prescriptive right to cross the railroad track is, that, in order to have done so, he and his grantors must have continuously violated the Pub. Sts. a. 112, §§ 195, 198, and that such violations could confer no rights on the violator. Section 195, imposing a penalty on any person, “ without right, knowingly,” walking or standing on any railroad track, is first found in the St. of 1853, c. 414, § 4. Since that time it has been decided that, in the case of a public way, such a right may be acquired by prescription, although the effect of this section of the statute was not discussed. Fitchburg Railroad v. Page, 131 Mass. 391. There are intimations also, since the St. of 1853, that a private way may be thus acquired. Gay v. Boston & Albany Railroad, ubi supra. Wright v. Boston Albany Railroad, 142 Mass. 296. Deerfield v. Connecticut River Railroad, 144 Mass. 325. Section 198 makes it a penal offence to ride or drive a horse, without consent of a railroad corporation, on its road. The defendant contends that, under these sections, rights cannot be acquired by prescription, against another or his property, by acts done in violation of the absolute prohibition of a public statute, that such acts where expressly prohibited are illegal in their inception and continuance, and cannot become lawful, as against individual members of the public, however long they may have been exercised. It is urged that, “ when a statute forbids anything to be done, the right to do it is not to be granted or acquired.” This contention, apparently drawn from the case of Brookline v. Mackintosh, 133 Mass. 215, 225, is there applied to a claim of a prescriptive right to defile a stream of water by pouring into it deleterious substances contrary to law, which right it was not in the power of any one to grant. Such an act, for public reasons, was one expressly prohibited to all. The argument has no proper application where the act done is or is not lawful according as it may have been done by right or with the consent of the party claiming to be injured, or as it may have been done against right or without such consent. The acts forbidden by §§ 195, 198, are so only when done without *437consent, but they may be permitted by the railroad corporation. The right to maintain a private crossing is also one which the railroad might grant, and to which it could give consent. The acts done in assertion of such a right, or by virtue of such an alleged consent, are not to be treated as originally wrongful, when they have been continued over twenty years, and when the party affected thereby has acquiesced for that length of time.
The defendant further urges, that it is impossible to gain a right of way over a railroad in actual operation, as the land of the railroad would be subject to the easement of the plaintiff, who might make use of it at his own pleasure. The case does not require us to define the exact limits of the right which the plaintiff has acquired. But it does not follow that, even if he has an easement, it is not one which he is compelled to exercise, subject to the superior right of the railroad corporation to run its trains, as it may determine to be proper for the general business of its road. There certainly may be an easement which will permit a way to be used only at particular times or seasons, or for particular purposes. As there may be by grant a right to cross a railroad when the trains of- the corporation are not passing, so such a right may be acquired.
It is contended that the defendant has, under the St. of 1874, o. 401, a right to take lands for railroad purposes ; that “ lands ” includes rights of way; and that, if the plaintiff’s rights are interfered with, his remedy is by application to the county commissioners. This statute gives to the defendant a right to relocate its railroad, and for that purpose, upon proper proceedings, to take other lands than those thus occupied by it; but the case affords no evidence that such proceedings have been had, nor does it appear that the agreed statement of facts was intended to bring any such question before us.
It must be assumed that the defendant had knowledge of the acts of the plaintiff, as they were open and adverse, although such knowledge is not stated, in terms, in the statement of facts. The statement also fails to show precisely what the acts of the defendant were, although it refers to them as those declared on. These are alleged in the declaration to have been the erection of a fence across the way used by the plaintiff, filling and placing *438upon it stones, ties, gravel, and iron rails, so as to render it impassable as a carriageway, and with great difficulty as a foot-way. The statement finds that the acts done by the defendant were done “ in the construction and maintenance of its railroad, which it was authorized by law to construct and maintain.” If the meaning of this is that the acts done by the defendant were done as a part of the necessary repair of its road, and were appropriate for that purpose, and that interference with the plaintiff’s way was necessarily incidental to such repair, there would be strong ground to argue that the plaintiff had, and could acquire, no right which interfered with this, and that such a right of the defendant was necessarily superior to any which the plaintiff could have acquired. But an examination of the whole facts, taken in connection with the arguments submitted,* leads us to the conclusion that the obstacle to the plaintiff was a permanent one, that its purpose was simply to deprive the plaintiff of the use of the way, and that it was in no other sense an act done in the maintenance of its road by the defendant.
We have not found it necessary to consider whether the plaintiff was entitled to a way by necessity.
Judgment affirmed.
The argument of the defendant on this point was as follows : “ Even if the plaintiff has succeeded in showing that he was entitled to a right of way across the railroad, he has not shown that the railroad company has unlawfully interfered with the same. The railroad company has a perfect right to use the whole location for railroad purposes, and for constructing the necessary tracks, buildings, and other structures thereon. Boston Gas Light Co. v. Old Colony & Newport Railway, 14 Allen, 444.”