OPINION OF AKIN GUMP STRAUSS HAUER & FELD LLP
Published on July 9, 2007

Exhibit 5.1
July 6, 2007
Quanta Services, Inc.
1360 Post Oak Boulevard
Suite 2100
Houston, TX 77056
1360 Post Oak Boulevard
Suite 2100
Houston, TX 77056
Re: Quanta
Services, Inc., Registration Statement on Form S-4 (Registration No. 333-142279)
|
Ladies and Gentlemen:
We have acted as counsel to Quanta Services, Inc., a Delaware corporation (the Company), in
connection with the registration, pursuant to a registration
statement on Form S-4, as amended (the Registration Statement), filed with the Securities and Exchange
Commission under the Securities Act of 1933, as amended (the Act), relating to the issuance by
the Company of the Companys common stock, par value $0.00001 per share (the Common Shares),
together with the associated preferred stock purchase rights issued pursuant to the Amended and
Restated Rights Agreement, dated as of March 8, 2000 and amended and restated as of October 24,
2002, between the Company and American Stock Transfer & Trust Company, as Rights Agent (the
Preferred Stock Purchase Rights and, together with the Common Shares, the Company Shares), in
connection with the merger (the Merger) of InfraSource Services, Inc., a Delaware corporation
(InfraSource), with and into Quanta MS Acquisition, Inc., a Delaware corporation and a wholly
owned subsidiary of Quanta (Quanta MS) pursuant to the Agreement and Plan of Merger (the Merger
Agreement), dated as of March 18, 2007 by and among the Company, Quanta MS and InfraSource.
We have examined originals or certified copies of such corporate records of the Company and
other certificates and documents of officials of the Company, public officials and others as we
have deemed appropriate for purposes of this letter. We have assumed the genuineness of all
signatures, the authenticity of all documents submitted to us as originals, the conformity to
authentic original documents of all copies submitted to us as conformed and certified or
reproduced copies.

Quanta Services, Inc.
July 6, 2007
Page 2
July 6, 2007
Page 2
Based upon the foregoing and subject to the assumptions, exceptions, qualifications and
limitations set forth hereinafter, we are of the opinion that,
assuming the
terms of the issuance of the Company Shares were established in conformity with the
Companys certificate of incorporation, and when (a) the Registration Statement
relating to the Company Shares has become effective under the Act, (b) the stockholders of the
Company have approved the issuance of the Company Shares in
connection with the Merger, (c) the stockholders of InfraSource have approved and
adopted the Merger Agreement and (d) the other conditions to consummating the transactions
contemplated by the Merger Agreement have been satisfied, the Company Shares will be duly
authorized and the Company Shares, when issued and delivered in accordance with the terms and
conditions of the Merger Agreement, will be validly issued, fully paid and non-assessable.
The opinions and other matters in this letter are qualified in their entirety and subject to
the following:
A. | We express no opinion as to the laws of any jurisdiction other than any published constitutions, treaties, laws, rules or regulations or judicial or administrative decisions of the General Corporation Law of the State of Delaware. | ||
B. | This law firm is a registered limited liability partnership organized under the laws of the State of Texas. | ||
C. | This letter is limited to the matters stated herein, and no opinions are implied or may be inferred beyond the opinions expressly stated. This letter speaks as of its date, and we undertake no, and hereby disclaim any, obligation to update this letter. |
We hereby consent to the filing of this letter as an exhibit to the Registration Statement and
to the use of our name in the prospectus forming a part of the Registration Statement under the
caption Legal Matters. In giving this consent, we do not thereby admit that we are within the
category of persons whose consent is required under Section 7 of the Act and the rules and
regulations thereunder.
Very truly yours,
Akin Gump Strauss Hauer & Feld LLP